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

solve :: String -> Int
solve cs = (\(_, s, t) -> s + t) $ foldr f (0, 0, 0) cs
  where
    f 'T' (d, s, t)             = (succ d,      s, succ t)
    f 'S' (d, s, t) | d == 0    = (     d, succ s,      t)
                    | otherwise = (pred d,      s, pred t)
