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

local counter=10^9
for i=1,n do
    local left=#s:sub(1,i-1):gsub("E","")
    local right=#s:sub(i+1):gsub("W","")
    counter=math.min(counter,left+right)
end
print(counter)