X=list(map(str,input()))
t=0
s=0
i=0
TL=0
SR=0
h=len(X)//2
#print(h,len(X))
while s==0:
  if X[i]=="T":
    TL=TL+1
    i=i+1
    #print("i",i,"TL",TL)
  else:
    s=s+1
    break
i=len(X)-1
while t==0:
  if X[i]=="S":
    SR=SR+1
    i=i-1
    #print("i",i,"SR",SR)
  else:
    t=t+1
    break
print(max(SR,TL)*2)