n = int(eval(input()))

s = eval(input())

dp_L = [0]*(n+1)

dp_R = [0]*(n+1)



for i in range(n):

    dp_L[i+1] = dp_L[i]+[0, 1][s[i] == 'W']



for i in reversed(list(range(n))):

    dp_R[i] = dp_R[i+1]+[0, 1][s[i] == 'E']

    

print((min(L+R for L, R in zip(dp_L, dp_R))))

n = int(eval(input()))

s = eval(input())

cnt_R = s.count('E')

cnt_L = 0

INF = 10**18

ans = INF

for x in s:

    if x == 'W':

        ans = min(ans, cnt_L+cnt_R)

        cnt_L += 1

    else:

        cnt_R -= 1

        ans = min(ans, cnt_L+cnt_R)

print(ans)

n = int(eval(input()))
s = eval(input())
dp_L = [0] * (n + 1)
dp_R = [0] * (n + 1)
for i in range(n):
    dp_L[i + 1] = dp_L[i] + [0, 1][s[i] == "W"]
for i in reversed(list(range(n))):
    dp_R[i] = dp_R[i + 1] + [0, 1][s[i] == "E"]
print((min(L + R for L, R in zip(dp_L, dp_R))))

n = int(eval(input()))
s = eval(input())
cnt_R = s.count("E")
cnt_L = 0
INF = 10**18
ans = INF
for x in s:
    if x == "W":
        ans = min(ans, cnt_L + cnt_R)
        cnt_L += 1
    else:
        cnt_R -= 1
        ans = min(ans, cnt_L + cnt_R)
print(ans)

-dp_L = [0] * (n + 1) -dp_R = [0] * (n + 1) -for i in range(n): -    dp_L[i + 1] = dp_L[i] + [0, 1][s[i] == "W"] -for i in reversed(list(range(n))): -    dp_R[i] = dp_R[i + 1] + [0, 1][s[i] == "E"] -print((min(L + R for L, R in zip(dp_L, dp_R)))) +cnt_R = s.count("E") +cnt_L = 0 +INF = 10**18 +ans = INF +for x in s: +    if x == "W": +        ans = min(ans, cnt_L + cnt_R) +        cnt_L += 1 +    else: +        cnt_R -= 1 +        ans = min(ans, cnt_L + cnt_R) +print(ans)