import Control.Applicative
import Control.Monad
import Data.List

f :: String -> (Int, Int)
f s = g (0, 0) s

g (x, y) [c] = if x>y then (x+1, y) else (x, y+1)
g (x, y) (_:ds@(d:_))
  | d == 'A' = g (x+1, y) ds
  | d == 'B' = g (x, y+1) ds

main = map f . takeWhile (/="0") . lines <$> getContents >>= mapM_ (\(x, y) -> putStrLn $ show x ++ " " ++ show y)
