x=input()
n=len(x)
s_count=0
t_count=0
for i in x:
    if i == "T" : t_count+=1
    else : s_count+=1
    if t_count > s_count:
        n-=s_count*2
        s_count=0
        t_count=0
print(n)        