import kotlin.math.*
import java.util.*

const val MOD = 1_000_000_007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

data class Seq(val c: Char, var n: Int)

fun finish(seq: List<Seq>, start: Int, end: Int): Boolean {
  return end - start == 1 && (
    (seq[start].c == 'R' && seq[end].c == 'W') ||
    (seq[start].c == 'R' && seq[end].c == 'R') ||
    (seq[start].c == 'W' && seq[end].c == 'W')
  )
}

fun main(args: Array<String>) {
  val n = readI()
  val s = readLine()!!
  val list = mutableListOf<Seq>()
  var i = 0
  while (i < n) {
    val j = i
    while (i + 1 < n && s[i] == s[i + 1]) i++
    list += Seq(s[j], i - j + 1)
    i++
  }
  var ans = 0
  var start = 0
  var end = list.size - 1
  do {
    while (start < end && list[start].c == 'R') start++
    while (start < end && list[end].c == 'W') end--
    if (end <= start) break

    val a = list[start]
    val b = list[end]
    if (a.n == b.n) {
      ans += a.n
      start++
      end--
    } else if (a.n < b.n) {
      ans += a.n
      start++
      b.n -= a.n
    } else {
      ans += b.n
      end--
      a.n -= b.n
    }
  } while (!finish(list, start, end))
  println(ans)
}
