x=input()
ans=0
for i in range(len(x)):
    if x[i]=="T":
        ans+=1
    else:break    
for j in range(-1,-len(x),-1):
    if x[j]=="S":
        ans+=1
    else:break    
x=x[i:j+1]
print(ans+abs(x.count("T")-x.count("S")))