main = do
  x <- getLine

  let solve (c:ss) ns nst len | c == 'S' = solve ss (ns+1) nst (len+1)
                              | c == 'T' = if ns > 0
                                           then solve ss (ns-1) (nst+1) (len+1)
                                           else solve ss ns nst (len+1)
      solve [] _ nst len = len - 2 * nst

  print $ solve x 0 0 0