-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import qualified Data.Sequence as Seq
import Data.Foldable (or)

naive :: U.Vector Bool -> Int
naive v = let s0 = Seq.fromFunction (U.length v) (v U.!)
          in loop 0 [s0]
  where
    loop !i ss = let ss' = map oneStep ss
                 in if any null ss' then
                      i
                    else
                      loop (i+1) $ concat ss'

oneStep :: Seq.Seq Bool -> [Seq.Seq Bool]
oneStep s = let (s0,s1') = Seq.spanl not s
                (s2,s1) = Seq.spanr id s1'
            in if Seq.null s1 then
                 []
               else
                 [ Seq.update j True $ Seq.update i False s1
                 | i <- Seq.elemIndicesL True s1
                 , j <- Seq.elemIndicesR False s1
                 ] ++
                 [ Seq.update i False s1
                 | i <- Seq.elemIndicesL True s1
                 ] ++
                 [ Seq.update j True s1
                 | j <- Seq.elemIndicesR False s1
                 ]

main = do
  n <- readLn @Int
  s <- BS.getLine -- 'R' or 'W'
  -- 操作後： replicate k 'R' ++ replicate (n - k) 'W' for some k
  let v = U.generate n (\i -> s `BS.index` i == 'W')
  print $ naive v
