N = int(eval(input()))

S = eval(input())



leftWest = 0

rightEast = S.count("E")



ans = 10 ** 6

for i in range(len(S)):

    if S[i] == "E":

        rightEast -= 1

    

    ans = min(ans, leftWest + rightEast)



    if S[i] == "W":

        leftWest += 1



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

S = eval(input())



leftWest = 0

rightEast = list(S).count("E")



ans = 10 ** 6

for si in S:

    if si == "E":

        rightEast -= 1

    

    ans = min(ans, leftWest + rightEast)



    if si == "W":

        leftWest += 1



print(ans)
N = int(eval(input()))
S = eval(input())
leftWest = 0
rightEast = S.count("E")
ans = 10**6
for i in range(len(S)):
    if S[i] == "E":
        rightEast -= 1
    ans = min(ans, leftWest + rightEast)
    if S[i] == "W":
        leftWest += 1
print(ans)

N = int(eval(input()))
S = eval(input())
leftWest = 0
rightEast = list(S).count("E")
ans = 10**6
for si in S:
    if si == "E":
        rightEast -= 1
    ans = min(ans, leftWest + rightEast)
    if si == "W":
        leftWest += 1
print(ans)

-rightEast = S.count("E") +rightEast = list(S).count("E") -for i in range(len(S)): -    if S[i] == "E": +for si in S: +    if si == "E": -    if S[i] == "W": +    if si == "W":