# coding: utf-8

N = int(eval(input()))

S = eval(input())



w, e = 0, 0

for i in range(N):

    if S[i] == "E":

        e += 1

ans = e



for i in range(N):

    if S[i] == "E":

        e -= 1

    ans = min(ans, e+w)

    

    if S[i] == "W":

        w += 1

print(ans)
# coding: utf-8

N = int(eval(input()))

S = eval(input())

e, w = 0, 0

e = S.count("E")

ans = e

for i in range(N):

    if S[i] == "E":

        e -= 1

        ans = min(ans, e+w)

    else:

        w += 1

print(ans)
# coding: utf-8
N = int(eval(input()))
S = eval(input())
w, e = 0, 0
for i in range(N):
    if S[i] == "E":
        e += 1
ans = e
for i in range(N):
    if S[i] == "E":
        e -= 1
    ans = min(ans, e + w)
    if S[i] == "W":
        w += 1
print(ans)

# coding: utf-8
N = int(eval(input()))
S = eval(input())
e, w = 0, 0
e = S.count("E")
ans = e
for i in range(N):
    if S[i] == "E":
        e -= 1
        ans = min(ans, e + w)
    else:
        w += 1
print(ans)

-w, e = 0, 0 -for i in range(N): -    if S[i] == "E": -        e += 1 +e, w = 0, 0 +e = S.count("E") -    ans = min(ans, e + w) -    if S[i] == "W": +        ans = min(ans, e + w) +    else: