x=list(input())
s=0
t=0
ans=len(x)
for i in range(len(x)):
    if x[i]=='S':
        ans-=2*min(s,t)
        s+=1
        t=0
    elif x[i]=='T':
        t+=1
    if i==len(x)-1:
        ans-=2*min(s,t)
print(ans)