N = int(eval(input()))

S = eval(input())

ans = N

E = [0] * (N + 1)

for i in range(N):

    E[i+1] = E[i] + (S[i] == 'E')

for i in range(N):

    LR = i - E[i] + E[N] - E[i+1]

    if LR < ans: ans = LR

print(ans)
eval(input())

S = eval(input())

res = cnt = S.count('E')

for c in S:

    cnt -= c == 'E'

    res = min(res, cnt)

    cnt += c == 'W'

print(res)
N = int(eval(input()))
S = eval(input())
ans = N
E = [0] * (N + 1)
for i in range(N):
    E[i + 1] = E[i] + (S[i] == "E")
for i in range(N):
    LR = i - E[i] + E[N] - E[i + 1]
    if LR < ans:
        ans = LR
print(ans)

eval(input())
S = eval(input())
res = cnt = S.count("E")
for c in S:
    cnt -= c == "E"
    res = min(res, cnt)
    cnt += c == "W"
print(res)

-N = int(eval(input())) +eval(input()) -ans = N -E = [0] * (N + 1) -for i in range(N): -    E[i + 1] = E[i] + (S[i] == "E") -for i in range(N): -    LR = i - E[i] + E[N] - E[i + 1] -    if LR < ans: -        ans = LR -print(ans) +res = cnt = S.count("E") +for c in S: +    cnt -= c == "E" +    res = min(res, cnt) +    cnt += c == "W" +print(res)