Scanf.scanf "%d %s" (fun n s ->
    let rec loop i r =
        if i = n then r else
            if s.[i] = 'R' then loop (i + 1) (r + 1) else loop (i + 1) r
    in
    let r = loop 0 0 in

    let rec loop i leftw =
        if i = r then leftw else
            loop (i + 1) (if s.[i] = 'W' then leftw + 1 else leftw)
    in
    let leftw = loop 0 0 in
    Printf.printf "%d\n" leftw
)