N = int(eval(input()))

S = eval(input())



w_left = 0

e_right = S[1:].count("E")

ans = float('inf')

for i in range(N):

    if i != 0:

        if S[i] == "E":

            e_right -= 1

        if S[i-1] == "W":

            w_left += 1

    ans = min(ans, w_left + e_right)

print(ans)

N = int(eval(input()))

S = list(eval(input()))



e_cnt = S.count('E')

w_cnt = 0

ans = float('inf')

for i in range(N):

    if S[i] == 'E':

        e_cnt -= 1

        w = w_cnt

    else:

        w_cnt += 1

        w = w_cnt - 1

    

    ans = min(ans, e_cnt+w)



print(ans)
N = int(eval(input()))
S = eval(input())
w_left = 0
e_right = S[1:].count("E")
ans = float("inf")
for i in range(N):
    if i != 0:
        if S[i] == "E":
            e_right -= 1
        if S[i - 1] == "W":
            w_left += 1
    ans = min(ans, w_left + e_right)
print(ans)

N = int(eval(input()))
S = list(eval(input()))
e_cnt = S.count("E")
w_cnt = 0
ans = float("inf")
for i in range(N):
    if S[i] == "E":
        e_cnt -= 1
        w = w_cnt
    else:
        w_cnt += 1
        w = w_cnt - 1
    ans = min(ans, e_cnt + w)
print(ans)

-S = eval(input()) -w_left = 0 -e_right = S[1:].count("E") +S = list(eval(input())) +e_cnt = S.count("E") +w_cnt = 0 -    if i != 0: -        if S[i] == "E": -            e_right -= 1 -        if S[i - 1] == "W": -            w_left += 1 -    ans = min(ans, w_left + e_right) +    if S[i] == "E": +        e_cnt -= 1 +        w = w_cnt +    else: +        w_cnt += 1 +        w = w_cnt - 1 +    ans = min(ans, e_cnt + w)