{-# LANGUAGE BangPatterns, MultiWayIf #-}

import Control.Applicative
import Control.Monad
import Data.List

solve :: String -> Int
solve xs = go 0 0 xs
  where
    go !ans !s []     = ans + s
    go !ans !s (y:ys)
        | y == 'S'  = go ans (s + 1) ys
        | otherwise = if s == 0
            then go (ans + 1) s ys
            else go ans (s - 1) ys

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