N = int(eval(input()))

S = list(eval(input()))



s = [0]*(N+1)



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

    k = 0

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

        k = 1

    s[i] = s[i-1] + k



ans = N

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

    k = (N - i) - (s[N] - s[i])

    ans = min(ans, k + s[i-1])





print(ans)

N = int(eval(input()))

S = eval(input())



L = [0]*N



l = 0

for i, x in enumerate(S):

    L[i] += l

    if x == 'E':

        l += 1

r = 0

for i, x in enumerate(S[::-1]):

    L[N-1-i] += r

    if x == 'W':

        r += 1



print((N-1 - max(L)))

N = int(eval(input()))
S = list(eval(input()))
s = [0] * (N + 1)
for i in range(1, N + 1):
    k = 0
    if S[i - 1] == "W":
        k = 1
    s[i] = s[i - 1] + k
ans = N
for i in range(1, N + 1):
    k = (N - i) - (s[N] - s[i])
    ans = min(ans, k + s[i - 1])
print(ans)

N = int(eval(input()))
S = eval(input())
L = [0] * N
l = 0
for i, x in enumerate(S):
    L[i] += l
    if x == "E":
        l += 1
r = 0
for i, x in enumerate(S[::-1]):
    L[N - 1 - i] += r
    if x == "W":
        r += 1
print((N - 1 - max(L)))

-S = list(eval(input())) -s = [0] * (N + 1) -for i in range(1, N + 1): -    k = 0 -    if S[i - 1] == "W": -        k = 1 -    s[i] = s[i - 1] + k -ans = N -for i in range(1, N + 1): -    k = (N - i) - (s[N] - s[i]) -    ans = min(ans, k + s[i - 1]) -print(ans) +S = eval(input()) +L = [0] * N +l = 0 +for i, x in enumerate(S): +    L[i] += l +    if x == "E": +        l += 1 +r = 0 +for i, x in enumerate(S[::-1]): +    L[N - 1 - i] += r +    if x == "W": +        r += 1 +print((N - 1 - max(L)))