N = int(eval(input()))

S = eval(input())



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

ans = [i]



for n in range(N):

    if n == 0:

        continue



    if S[n] == 'E':

        i -= 1



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

        i += 1

    ans.append(i)



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

S = eval(input())



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

r = [i]



for n in range(1, N):

    if S[n] == 'E':

        i -= 1



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

        i += 1

    r.append(i)



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

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

-ans = [i] -for n in range(N): -    if n == 0: -        continue +r = [i] +for n in range(1, N): -    ans.append(i) -print((min(ans))) +    r.append(i) +print((min(r)))