import qualified Data.ByteString.Char8 as BS

main = BS.getLine >>= print . compute

compute :: BS.ByteString -> Int
compute = uncurry (+) . BS.foldl' step (0,0)

-- (Tをやり過ごした数, Sの余っている数)
step :: (Int,Int) -> Char -> (Int,Int)
step (t,s) 'S' = (t, succ s)
step (t,0) 'T' = (succ t, 0)
step (t,s) 'T' = (t, pred s)
