x = input()
#tのラストとsの最初を知りたい
n = len(x)
t1 = 0
s1 = 0
a = 0
su = 0
for i in range(n):
  if x[i]=="T":
    t1 = i
  else:
    if a==0:
      s1 = i
      a = 1
#print(t1,s1)
#後ろにあるSは残る
sn = n//2-(n-t1-1)
tn = n//2-(s1)
su = 2*min(sn,tn)
print(n-su)