local n = io.read("*n", "*l")
local str = io.read()
local cnt = {}
local t_cnt = 0
for i = 1, n do
  if(str:sub(i, i) == "E") then
    t_cnt = t_cnt + 1
  end
  cnt[i] = t_cnt
end
local minret = n
for i = 1, n do
  local ret = 0
  if(1 < i) then
    ret = ret + ((i - 1) - cnt[i - 1])
  end
  if(i < n) then
    ret = ret + cnt[n] - cnt[i]
  end
  minret = math.min(minret, ret)
end
print(minret)

