N = gets.to_i
S = gets.chomp
R = Array.new(N + 1, 0)
(1 .. N).each do |n|
  if S[n - 1] == 'R'
    R[n] = R[n - 1] + 1
  else
    R[n] = R[n - 1]
  end
end

dp = Array.new(N + 1, 0)
(0 .. N).each do |n|
  lw = n - R[n]
  rr = R[N] - R[n]
  dp[n] = [lw, rr].min + (lw - rr).abs
end
puts dp.min
