N = int(eval(input()))

S = eval(input())



cumw = [0]

for c in S:

    cumw.append(cumw[-1] + int(c=='W'))



ans = N

for i in range(N):

    tmp = cumw[i]

    tmp += (N-i-1) - (cumw[-1]-cumw[i+1])

    ans = min(ans,tmp)

print(ans)
N = int(eval(input()))

S = eval(input())



cum_e = [0]

for c in S:

    cum_e.append(cum_e[-1] + int(c == 'E'))



ans = N

for i in range(N):

    tmp = i - cum_e[i] + cum_e[-1] - cum_e[i+1]

    ans = min(ans, tmp)

print(ans)
N = int(eval(input()))
S = eval(input())
cumw = [0]
for c in S:
    cumw.append(cumw[-1] + int(c == "W"))
ans = N
for i in range(N):
    tmp = cumw[i]
    tmp += (N - i - 1) - (cumw[-1] - cumw[i + 1])
    ans = min(ans, tmp)
print(ans)

N = int(eval(input()))
S = eval(input())
cum_e = [0]
for c in S:
    cum_e.append(cum_e[-1] + int(c == "E"))
ans = N
for i in range(N):
    tmp = i - cum_e[i] + cum_e[-1] - cum_e[i + 1]
    ans = min(ans, tmp)
print(ans)

-cumw = [0] +cum_e = [0] -    cumw.append(cumw[-1] + int(c == "W")) +    cum_e.append(cum_e[-1] + int(c == "E")) -    tmp = cumw[i] -    tmp += (N - i - 1) - (cumw[-1] - cumw[i + 1]) +    tmp = i - cum_e[i] + cum_e[-1] - cum_e[i + 1]