def solve():
  s =input()
  n =len(s)
  #Tの位置とSの位置がほしい
  places = []
  placet = []
  for i in range(n):
    if s[i] == 'S':places.append(i)
    else: placet.append(i)
  places = places[::-1]
  placet = placet[::-1]
  ct = 0
  for j in places:
    if j < placet[0]:
      ct += 2
      placet.pop(0)
  return (n-ct)  
  
  
if __name__ == '__main__':
  print(solve())