import qualified Data.ByteString.Char8 as B
import Data.Maybe

readInts :: IO [Int]
readInts = map readInt . B.words <$> B.getLine

readInt :: B.ByteString -> Int
readInt = fst . fromJust . B.readInt

main = do
  s <- getLine
  print (st_ring s)

st_ring = length . foldr remove ""

remove 'S' ('T':acc) = acc
remove c acc = c : acc