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