import Data.Function
import Data.List

main :: IO ()
main = do
  l1 <- getLine
  let [n, m] = map read $ words l1 :: [Int]
  ls <- sequence $ replicate m getLine
  let ps = map (f . words) ls :: [(Int, String)]
  putStrLn $ unwords $ map show $ g ps

f [ps, s] = (read ps, s)

g :: [(Int, String)] -> [Int]
g l = [length l''', sum $ map (length . fst) l''']
  where
    l' = groupBy ((==) `on` fst) l
    l'' = map (span (=="WA") . map snd) l'
    l''' = filter (not . null . snd) l''
