s=input();pd=0;n='';p=1
while(1):
    if s[pd]!='S' and s[pd+1]!='T':
        n=n+s[pd]
    pd+=1
    if pd==len(s)-2:
        pd=0
        s=n
        n=''
    p+=1
    if len(s)==2:
        break
    if p>=10000:
        break
print(len(s))