main = do
  s <- getLine
  print $ length $ solve s []

  where
    solve [] xs = xs
    solve (c:cs) list
      | c == 'S' = solve cs (c:list)
      | c == 'T' = if null list || head list == 'T' then solve cs (c:list) else solve cs (tail list)
