import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

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

solve :: String -> Int
solve cs = f 0 0 cs
  where
    f t s [] = t + s
    f t s (x:xs)
      | x == 'T' = if s > 0 then f t (s - 1) xs else f (t + 1) s xs
      | otherwise = f t (s + 1) xs

getl :: (String -> a) -> IO a
getl f = f <$> getLine
