{-# LANGUAGE OverloadedStrings #-}
import Control.Applicative
import Data.List (group)

solve :: [String] -> Int -> Int
solve [] c = c
solve [x] c = length x+c
solve (s:t:ss) c =
  if head s == 'S'
    then solve ss (c+length s-l+length t-l)
    else solve (t:ss) (c+length s)
  where l = min (length s) (length t)

main = do
  ss <- group <$> getLine
  print $ solve ss 0
