n = gets.to_i
c = gets.chomp
x = c.count("R")
y = c.count("W")
z = 10**9
arr = []
if c[0] == "W"
    arr << 1
else
    arr << 0
end
for i in 1..(n-1)
  if c[i] == "W"
    arr << arr[-1] + 1
  else
    arr << arr[-1]
  end
end
for j in 0..(n-2)
  if c[j] != c[j+1]
    zz = [arr[j],n-j-1-y+arr[j]].max
    z = zz if zz < z
  end
end
puts [x,y,z].min