n = input()
co = 0
su = 0
for i in range(len(n)):
  if n[-(i+1)] == "S":
    co += 1
  else:
    break
for i in range(len(n)):
    if n[i] == "T":
        su += 1
    else:
        break
print(max(su,co)*2)
