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++ (GCC 9.2.1) (judge verdict: Accepted)

//HOW YOU DOI'N......................

#include <bits/stdc++.h>
#include <queue>
#include <string.h>
#include <stdint.h>
#include <cmath>

#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);

#define ll long long
#define ld long double
#define ull unsigned long long
#define ut uint64_t

#define pb push_back
#define ins insert
#define er erase

#define fi(i, b) for (int i=0;i<b;i++)
#define fll(i, b) for (ll i=0;i<b;i++)
#define fla(i,a,b) for (ll i=a;i<b;i++)

#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vb vector<bool>
#define vst vector<string>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvl vector<vector<ll>>


#define all(v) v.begin(), v.end()
#define lb lower_bound
#define ub upper_bound
#define mxe max_element
#define mne min_element

#define srt(v) sort(all(v))
#define rsrt(v) sort(v.rbegin(), v.rend())

#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second

#define mii map<int, int>
#define mll map<ll, ll>
#define umii unordered_map<int, int>
#define umll unordered_map<ll, ll>

#define si set<int>
#define sll set<ll>
#define usi unordered_set<int>
#define usll unordered_set<ll>
#define spii set<pii>
#define spll set<pll>

#define pqi priority_queue<int>
#define pqll priority_queue<ll>

 #define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a)*1ll * (b)) / gcd(a, b)

#define nl "\n"
#define sz(x)  (int)x.size()
using namespace std;

double PI = (acos(-1));

ll md = 1000000007;
ll ma = 998244353;

ll pw(ll a, ll b)
{
    ll c = 1, m = a;
    while (b){
        if (b & 1)c = (c * m);
        m = (m * m);
        b /= 2;
    }
    return c;
}

ll pwmd(ll a, ll b){
    ll c = 1, m = a;
    while (b){
        if (b & 1)
            c = ((c * m)) % md;
        m = (m * m) % md;
        b /= 2;
    }
    return c;
}


ll modinv(ll n)
{
    return pwmd(n, md - 2);
}
ll min(ll a,ll b){
    if(a>=b)return b;
    return a;
}
ll nc2(ll n)
{
    return (1ll * n * (n - 1)) / 2;
}

ll nsum(ll n)
{
    return (1ll * n * (n + 1)) / 2;
}

bool is(string r)
{
    string p = r;
    reverse(p.begin(), p.end());
    return (r == p);
}





//vst choti_abcd={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vst badi_abcd={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};

bool prime(ll a){
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }return true;
}

// Lets start ...
#define MAX_SIZE 1005
void SieveOfEratosthenes(vector<int> &primes)
{
	bool IsPrime[MAX_SIZE];
	memset(IsPrime, true, sizeof(IsPrime));

	for (int p = 2; p * p < MAX_SIZE; p++)
	{
		if (IsPrime[p] == true)
		{
			for (int i = p * p; i < MAX_SIZE; i += p)
				IsPrime[i] = false;
		}
	}
	for (int p = 2; p < MAX_SIZE; p++)
	if (IsPrime[p])
			primes.push_back(p);

}

void solve(){
    
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    ll i=0,j=n-1;
    while(true){
        if(s[i]=='W'&&s[j]=='R')ans++,i++,j--;
        else{
            if(s[i]!='W')i++;
            if(s[j]!='R')j--;
        }
        if(i>=j)break;
    }cout<<ans<<nl;
}
    
    
    


int main(){
    //vi primes;
    //SieveOfEratosthenes(primes);
    
    
    
    fast;
    ll tests=1;
    //cin>>tests;
    while(tests--){
        solve();
        
        
    }

    return 0;
    }

// Done:)