main :: IO ()
main = do
  sts <- getLine
  print $ solve sts

solve :: String -> Int
solve = length . go []
  where
    go acc       []        = acc
    go acc       ('S':sts) = go ('S':acc) sts
    go ('S':acc) ('T':sts) = go acc sts
    go acc       (c:sts)   = go (c:acc) sts
