local mmi, mma = math.min, math.max
local n = io.read("*n", "*l")
local s = io.read()
local t = {}
for i = 1, n do
  t[i] = s:sub(i, i) == "W"
end
local left, right = {}, {}
do
  local c = 0
  for i = 1, n do
    if t[i] then c = c + 1 end
    left[i] = c
    right[i] = 0
  end
  c = 0
  for i = n, 1, -1 do
    if t[i] then c = c + 1 end
    right[i] = c
  end
end
local ret = mmi(n - right[1], left[n])
for i = 1, n - 1 do
  local need_red = left[i]
  local need_white = n - i - right[i + 1]
  ret = mmi(ret, mma(need_red, need_white))
end
print(ret)
