
X = input()
s = 0
t = 0
ans = len(X)
for c in X:
    if c == 'T':
        t += 1
    elif t > 0:
        ans -= min(s, t) * 2
        s = t = 0
    if c == 'S':
        s += 1
if t > 0:
    ans -= min(s, t) * 2
print(ans)