N = int(eval(input()))

S = eval(input())

l = 0

r = S[1:].count('E')

ans = l+r



for i in range(1, N):

    if S[i-1] == 'W':

        l += 1

    

    if S[i] == 'E':

        r -= 1

    ans = min(ans, r+l)



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

S = eval(input())

ans = [0] * N

ans[0] = S[1:].count('E')

num = ans[0]



for i in range(1, N):

    if S[i-1] == 'W':

        num += 1

    if S[i] == 'E':

        num -= 1

    ans[i] = num

    

print((min(ans)))
N = int(eval(input()))
S = eval(input())
l = 0
r = S[1:].count("E")
ans = l + r
for i in range(1, N):
    if S[i - 1] == "W":
        l += 1
    if S[i] == "E":
        r -= 1
    ans = min(ans, r + l)
print(ans)

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

-l = 0 -r = S[1:].count("E") -ans = l + r +ans = [0] * N +ans[0] = S[1:].count("E") +num = ans[0] -        l += 1 +        num += 1 -        r -= 1 -    ans = min(ans, r + l) -print(ans) +        num -= 1 +    ans[i] = num +print((min(ans)))