N = int(eval(input()))

S = list(eval(input()))



s = [0]*(N+1)

e = [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



for i in reversed(list(range(0, N))):

    k = 0

    if S[i] == "E":

        k = 1

    e[i] = e[i+1] + k



ans = N

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

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





print(ans)

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 = list(eval(input()))
s = [0] * (N + 1)
e = [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
for i in reversed(list(range(0, N))):
    k = 0
    if S[i] == "E":
        k = 1
    e[i] = e[i + 1] + k
ans = N
for i in range(1, N + 1):
    ans = min(ans, s[i - 1] + e[i])
print(ans)

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)

-e = [0] * (N + 1) -for i in reversed(list(range(0, N))): -    k = 0 -    if S[i] == "E": -        k = 1 -    e[i] = e[i + 1] + k -    ans = min(ans, s[i - 1] + e[i]) +    k = (N - i) - (s[N] - s[i]) +    ans = min(ans, k + s[i - 1])