import Control.Monad.Trans.State.Lazy( StateT, get, modify, evalStateT)
main = do
    x <- getLine
    let process [] = return []
	process [c] = return [c]
	process (c1:rem@(c2:cs)) = do
	    n <- get
	    if n==0 then return $ c1:rem
	    else if [c1,c2] == "ST"
		    then modify pred >> process cs
		    else do
			next <- process rem
			case next of
			    []	    -> return [c1]
			    (cc:ccs) -> if [c1,cc] == "ST"
				then modify pred >> return ccs
				else return $ c1:next
    print . length =<< evalStateT (process x) 100000