{-# LANGUAGE MultiWayIf #-}

solve :: String -> Int -> Int
solve [] _     = 0
solve (x:xs) n = if
  | x == 'S'  -> solve xs (n+1)
  | n > 0     -> solve xs (n-1)
  | otherwise -> 1 + solve xs 0

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