n = int(eval(input()))

s = eval(input())

e = [0]

w = [s[1:].count('E')]

for i in range(1, n):

  e.append(e[-1]+(s[i-1]=='W'))

  w.append(w[-1]-(s[i]=='E'))

print((min(a+b for a,b in zip(e,w))))
from itertools import accumulate



n, s = eval(input()), eval(input())



a = accumulate(c=='W' for c in 'X'+s[:-1])

b = reversed(list(accumulate(c=='E' for c in 'X'+s[-1:0:-1])))

print((min(x + y for x, y in zip(a, b))))
n = int(eval(input()))
s = eval(input())
e = [0]
w = [s[1:].count("E")]
for i in range(1, n):
    e.append(e[-1] + (s[i - 1] == "W"))
    w.append(w[-1] - (s[i] == "E"))
print((min(a + b for a, b in zip(e, w))))

from itertools import accumulate

n, s = eval(input()), eval(input())
a = accumulate(c == "W" for c in "X" + s[:-1])
b = reversed(list(accumulate(c == "E" for c in "X" + s[-1:0:-1])))
print((min(x + y for x, y in zip(a, b))))

-n = int(eval(input())) -s = eval(input()) -e = [0] -w = [s[1:].count("E")] -for i in range(1, n): -    e.append(e[-1] + (s[i - 1] == "W")) -    w.append(w[-1] - (s[i] == "E")) -print((min(a + b for a, b in zip(e, w)))) +from itertools import accumulate + +n, s = eval(input()), eval(input()) +a = accumulate(c == "W" for c in "X" + s[:-1]) +b = reversed(list(accumulate(c == "E" for c in "X" + s[-1:0:-1]))) +print((min(x + y for x, y in zip(a, b))))