Problem:
Score : 400 points

Problem Statement

An altar enshrines N stones arranged in a row from left to right. The color of the i-th stone from the left (1 \leq i \leq N) is given to you as a character c_i; R stands for red and W stands for white.

You can do the following two kinds of operations any number of times in any order:

Choose two stones (not necessarily adjacent) and swap them.

Choose one stone and change its color (from red to white and vice versa).

According to a fortune-teller, a white stone placed to the immediate left of a red stone will bring a disaster. At least how many operations are needed to reach a situation without such a white stone?

Constraints

2 \leq N \leq 200000

c_i is R or W.

Input

Input is given from Standard Input in the following format:

N
c_{1}c_{2}...c_{N}

Output

Print an integer representing the minimum number of operations needed.

Sample Input 1

4
WWRR

Sample Output 1

2

For example, the two operations below will achieve the objective.

Swap the 1-st and 3-rd stones from the left, resulting in RWWR.

Change the color of the 4-th stone from the left, resulting in RWWW.

Sample Input 2

2
RR

Sample Output 2

0

It can be the case that no operation is needed.

Sample Input 3

8
WRWWRWRR

Sample Output 3

3

Solution in C# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Numerics;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace debug
{
    class main
    {
        static void Main(string[] args)
        {
            //問題クラスを展開
            ProgramD a = new ProgramD();
            a.main();//実行する

        }

    }
    //ABC170
    class ProgramA
    {
        public void main()
        {
            //入力
            int x = int.Parse(Console.ReadLine());


            if (x >= 30)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

        }
    }

    class ProgramB
    {
        public void main()
        {
            //入力
            
            string[] s = Console.ReadLine().Split(' ');
            long n = long.Parse(s[0]);
            long d = long.Parse(s[1]);

            long count = 0;
            for(int i = 0; i < n;i++)
            {
                string[] t = Console.ReadLine().Split(' ');
                long x = long.Parse(t[0]);
                long y = long.Parse(t[1]);
                if (x * x + y * y <= d * d)
                    count++;
            }

            Console.WriteLine(count);

        }
    }

    class ProgramC
    {
        public void main()
        {

            //入力
            int k = int.Parse(Console.ReadLine());

            if(k % 2 == 0)
            {
                Console.WriteLine("-1");
                return;
            }

            if (7 % k == 0)
            {
                Console.WriteLine("1");
                return;
            }


            int flag = 0;
            long num = 7;
            long count = 1;

            while(flag == 0)
            {
                count++;
                num *= 10;
                num += 7;
                num %= k;
                if (num == 0)
                    flag = 1;
                if (count >= 10000000)
                {
                    Console.WriteLine("-1");
                    return;
                }
                
            }

            Console.WriteLine(count);




        }
    }

    class ProgramD
    {
        public void main()
        {

            //入力
            long n = long.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            int wc = 0;
            int rc = 0;
            for (int i = 0; i < n; i++)
            {
                if (s[i] == 'R')
                    rc++;
                else
                    wc++;
            }

            if (wc == 0)
            {
                Console.WriteLine("0");
                return;
            }

            int rw = 0;
            int ww = 0;

            for (int i = 0; i < rc; i++)
            {
                if (s[i] == 'W')
                    rw++;
            }

            for (int i = rc; i < n; i++)
            {
                if (s[i] == 'R')
                    ww++;
            }

            
            Console.WriteLine(Math.Min(rw,ww) + Math.Abs(rw - ww));
            

        }

    }

    class ProgramE
    {

        public void main()
        {
            //入力
            int t = int.Parse(Console.ReadLine());


            for(int x = 0;x < t;x++)
            {
                int n = int.Parse(Console.ReadLine());
                for(int i = 0;i < n;i++)
                {

                }

            }


        }


    }

}