n = int(eval(input()))

s = list(eval(input()))

# EりーだーW

cnt = [0] * (n+1)

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

    cnt[i] += cnt[i-1]

    if s[i-1] == "E": cnt[i] += 1



ans = float("INF")

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

    a = ((i-1) - cnt[i-1]) + (cnt[-1] - cnt[i])

    if ans > a: ans = a

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

s = eval(input())



# E:右　W:左

cnt = [0] * (n+1)

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

    cnt[i] += cnt[i-1]

    if s[i-1] == "E": cnt[i] += 1



ans = float("INF")

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

    a = ((i-1) - cnt[i-1]) + (cnt[-1]-cnt[i])

    if ans > a: ans = a

print(ans)
n = int(eval(input()))
s = list(eval(input()))
# EりーだーW
cnt = [0] * (n + 1)
for i in range(1, n + 1):
    cnt[i] += cnt[i - 1]
    if s[i - 1] == "E":
        cnt[i] += 1
ans = float("INF")
for i in range(1, n + 1):
    a = ((i - 1) - cnt[i - 1]) + (cnt[-1] - cnt[i])
    if ans > a:
        ans = a
print(ans)

n = int(eval(input()))
s = eval(input())
# E:右　W:左
cnt = [0] * (n + 1)
for i in range(1, n + 1):
    cnt[i] += cnt[i - 1]
    if s[i - 1] == "E":
        cnt[i] += 1
ans = float("INF")
for i in range(1, n + 1):
    a = ((i - 1) - cnt[i - 1]) + (cnt[-1] - cnt[i])
    if ans > a:
        ans = a
print(ans)

-s = list(eval(input())) -# EりーだーW +s = eval(input()) +# E:右　W:左