main = do
  x <- getLine
  print . length . g (length x) $ f x

f :: String -> String
f [] = []
f ('S':'T':xs) = f xs
f (x:xs) = x : f xs

g :: Int -> String -> String
g n xs
  | n == 0 = xs
  | length xs' < length xs = g (n - 1) xs'
  | otherwise = xs'
    where xs' = f xs