-- Try AtCoder
-- author: Leonardone @ NEETSDKASU

main = print . solve =<< getLine

solve xs = solveX 0 0 xs where
    solveX tc sc ('S':ss) = solveX tc (sc + 1) ss
    solveX tc  0 ('T':ss) = solveX (tc + 1) 0 ss
    solveX tc sc ('T':ss) = solveX tc (sc - 1) ss
    solveX tc sc [] = tc + sc