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



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



ans = 10 ** 6

for si in S:

    if si == "E":

        cost -= 1

    

    if cost < ans:

        ans = cost



    if si == "W":

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

-    ans = min(ans, cost) +    if cost < ans: +        ans = cost