x=input()
ans=len(x)
ind=x.find("ST")
while(ind!=-1):
    ans-=2
#     s_ind=ind-1
#     t_ind=ind+2
#     while(0<=s_ind and t_ind<len(x) and x[s_ind]=="S" and x[t_ind]=="T"):
#         ans-=2
#         s_ind-=1
#         t_ind+=1
    x=x[:ind]+x[ind+2:]
    ind=x.find("ST")
print(ans)