import Data.List

main = interact $ unlines . map (show . step_aerobics) . read' . lines
 where
  read' ("0":_) = []
  read' (_:steps:xs) = words steps : read' xs

step_aerobics steps = sum $ zipWith (\[_,l] [_,r] -> if l==r then 1 else 0) left right
 where
  left  = filter ((=='l') . head) steps
  right = filter ((=='r') . head) steps