main :: IO ()
main = do
  s <- getLine
  putStrLn $ show $ length $solve [] s 


solve :: String -> String -> String
solve stack [] = stack
solve [] (x:xs) = solve [x] xs
solve (s:st) (x:xs)
    | s == 'S' && x == 'T' = solve st xs
    | otherwise            = solve (x:s:st) xs