s=input()
n=len(s)
cs=ct=0
for i in range(n):
    if s[n-i-1]=="T":
        ct+=1
    else:
      break

for i in range(cs,n):
    if s[n-i-1]=="S":
      cs+=1
    else:
      break
      
remain=cs-ct
if remain<0:
    remain=0
ans=n-2*(s.count("S")-remain)
print(ans)