{-# LANGUAGE PatternSynonyms, ViewPatterns #-}

import Text.Printf
import Data.Sequence

func :: Seq Char -> Int
func (viewl -> EmptyL) = 0
func (viewl -> 'R' :< r) = func r
func (viewr -> l :> 'W') = func l
func (viewl -> 'W' :< (viewr -> m :> 'R')) = 1 + func m
func (viewl -> 'W' :< m) = 1 + func m
func (viewr -> m :> 'R') = 1 + func m

main :: IO ()
main = do
  _ <- getLine
  s <- getLine
  printf "%d\n" $ func $ fromList s