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())



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



ans = 10 ** 6

for si in S:

    if si == "E":

        cost -= 1

    

    ans = min(ans, cost)



    if si == "W":

        cost += 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())
cost = list(S).count("E")
ans = 10**6
for si in S:
    if si == "E":
        cost -= 1
    ans = min(ans, cost)
    if si == "W":
        cost += 1
print(ans)

-leftWest = 0 -rightEast = list(S).count("E") +cost = list(S).count("E") -        rightEast -= 1 -    ans = min(ans, leftWest + rightEast) +        cost -= 1 +    ans = min(ans, cost) -        leftWest += 1 +        cost += 1