x = list(input())

L = len(x)
now = len(x) - 1
while now >= 0 and L >= 2 :
    if now == L - 1 :
        now -= 1
        continue
    if x[now] == 'S' and x[now+1] == 'T' :
        x.pop(now+1)
        x.pop(now)
        L -= 2
    now -= 1

print(len(x))