#!/usr/bin/env python3
X = input()
sub = 0
tmp = 0
s, t, = 0, 0
for c in X:
    if c == 'S':
        if t != 0:
            sub += min(tmp, t)
            t = 0
        s += 1
    else:
        if s != 0:
            tmp = s
            s = 0
        t += 1
else:
    sub += min(tmp, t)
print(len(X) - 2 * sub)
