N = int(eval(input()))

S = eval(input())



E_count = [0] * (N+1)

for i in range(N):

    E_count[i+1] = E_count[i] + int(S[i] == "E")



W_count = [0] * (N+1)

for i in range(N):

    W_count[i+1] = W_count[i] + int(S[i] == "W")



ans = 10 ** 6

for i in range(1, N + 1):

    change_dir_cnt = (W_count[i - 1] - W_count[0]) + (E_count[-1] - E_count[i])

    ans = min(change_dir_cnt, ans)

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

S = eval(input())



E_count = [0] * (N+1)

W_count = [0] * (N+1)



for i in range(N):

    E_count[i + 1] = E_count[i] + int(S[i] == "E")

    W_count[i + 1] = (i + 1) - E_count[i + 1]



ans = 10 ** 6

for i in range(1, N + 1):

    change_dir_cnt = (W_count[i - 1] - W_count[0]) + (E_count[-1] - E_count[i])

    ans = min(change_dir_cnt, ans)

print(ans)
N = int(eval(input()))
S = eval(input())
E_count = [0] * (N + 1)
for i in range(N):
    E_count[i + 1] = E_count[i] + int(S[i] == "E")
W_count = [0] * (N + 1)
for i in range(N):
    W_count[i + 1] = W_count[i] + int(S[i] == "W")
ans = 10**6
for i in range(1, N + 1):
    change_dir_cnt = (W_count[i - 1] - W_count[0]) + (E_count[-1] - E_count[i])
    ans = min(change_dir_cnt, ans)
print(ans)

N = int(eval(input()))
S = eval(input())
E_count = [0] * (N + 1)
W_count = [0] * (N + 1)
for i in range(N):
    E_count[i + 1] = E_count[i] + int(S[i] == "E")
    W_count[i + 1] = (i + 1) - E_count[i + 1]
ans = 10**6
for i in range(1, N + 1):
    change_dir_cnt = (W_count[i - 1] - W_count[0]) + (E_count[-1] - E_count[i])
    ans = min(change_dir_cnt, ans)
print(ans)

+W_count = [0] * (N + 1) -W_count = [0] * (N + 1) -for i in range(N): -    W_count[i + 1] = W_count[i] + int(S[i] == "W") +    W_count[i + 1] = (i + 1) - E_count[i + 1]