local n=io.read("n","l")
local s=io.read()

local w={}
local e={}
local west=0
local east=0

for i=1,n do
    if s:sub(n-i+1,n-i+1)=="E" then
        west=west+1
    end
    if s:sub(i,i)=="W" then
        east=east+1
    end
    w[n-i+1]=west
    e[i]=east
end

local counter=10^9
for i=1,n do
    counter=math.min(counter,w[i]+e[i]-1)
end
print(counter)