{-# LANGUAGE BangPatterns #-}

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

solve :: String -> Int
solve cs = snd $ foldl f (0, 0) cs
  where
    f (!d, !x) 'S'             = (succ d, succ x)
    f (!d, !x) 'T' | d == 0    = (     d, succ x)
                   | otherwise = (pred d, pred x)

