a = raw_input()
while(a.find("ST") != -1):
  a = a.replace("ST","")
  a = a.replace("ST","")
  a = a.replace("ST","")
  a = a.replace("ST","")
  a = a.replace("ST","")
  a = a.replace("ST","")
print len(a)