N=io.read()
S=io.read()
count=0
for i=2,#S do
  if string.sub(S,i,i)=="E" then
    count=count+1
  end
end
k=count
for i=2,#S do
  if string.sub(S,i-1,i-1)=="W" then
    k=k+1
  end
  if string.sub(S,i,i)=="E" then
    k=k-1
  end
  if k<count then
    count=k
  end 
end
print(count)