{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import qualified Data.Text as T

solve :: T.Text -> T.Text
solve s =
  if s == s' then s else solve s'
  where s' = T.replace "ST" "" s

main = do
  s <- T.pack <$> getLine :: IO T.Text
  print $ T.length $ solve s
