n = int(eval(input()))

s = eval(input())



w = [0]

e = [0]

w_cnt = 0

e_cnt = 0

for i in range(n):

    if s[i] == "W":

        w_cnt += 1

    else:

        e_cnt += 1

    w.append(w_cnt)

    e.append(e_cnt)



ans = 10 ** 9

for i in range(n):

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

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

s = eval(input())



w_cnt = 0

e_cnt = 0

E = s.count("E")

ans = 10 ** 9



for i in s:

    if i == "E":

        e_cnt += 1

    ans = min(ans, w_cnt + E - e_cnt)

    if i == "W":

        w_cnt += 1



print(ans)
n = int(eval(input()))
s = eval(input())
w = [0]
e = [0]
w_cnt = 0
e_cnt = 0
for i in range(n):
    if s[i] == "W":
        w_cnt += 1
    else:
        e_cnt += 1
    w.append(w_cnt)
    e.append(e_cnt)
ans = 10**9
for i in range(n):
    ans = min(ans, w[i] + (e[-1] - e[i + 1]))
print(ans)

n = int(eval(input()))
s = eval(input())
w_cnt = 0
e_cnt = 0
E = s.count("E")
ans = 10**9
for i in s:
    if i == "E":
        e_cnt += 1
    ans = min(ans, w_cnt + E - e_cnt)
    if i == "W":
        w_cnt += 1
print(ans)

-w = [0] -e = [0] -for i in range(n): -    if s[i] == "W": +E = s.count("E") +ans = 10**9 +for i in s: +    if i == "E": +        e_cnt += 1 +    ans = min(ans, w_cnt + E - e_cnt) +    if i == "W": -    else: -        e_cnt += 1 -    w.append(w_cnt) -    e.append(e_cnt) -ans = 10**9 -for i in range(n): -    ans = min(ans, w[i] + (e[-1] - e[i + 1]))