N = int(eval(input()))

S = eval(input())



wc = [0]

ec = [0]



for i in range(N):

    if S[i] == "W":

        wc.append(wc[i]+1)

        ec.append(ec[i])

    else:

        wc.append(wc[i])

        ec.append(ec[i]+1)



#print("wc : {}, ec : {}".format(wc, ec))



ans = ec[N]

for i in range(1, N):

    #W -> cnt, E -> sum - cnt

    tmp = wc[i] + ec[N] - ec[i+1]

    ans = min(tmp, ans)



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

S = list(eval(input()))



ans = [0] * N

#リーダーより東の東向きの人

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



#リーダーを東にずらしていく

for i in range(1, N):

    ans[i] = ans[i-1]

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

        ans[i] += 1

    if S[i] == "E":

        ans[i] -= 1



#print("ans : {}".format(ans))

print((min(ans)))
N = int(eval(input()))
S = eval(input())
wc = [0]
ec = [0]
for i in range(N):
    if S[i] == "W":
        wc.append(wc[i] + 1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i] + 1)
# print("wc : {}, ec : {}".format(wc, ec))
ans = ec[N]
for i in range(1, N):
    # W -> cnt, E -> sum - cnt
    tmp = wc[i] + ec[N] - ec[i + 1]
    ans = min(tmp, ans)
print(ans)

N = int(eval(input()))
S = list(eval(input()))
ans = [0] * N
# リーダーより東の東向きの人
ans[0] = S[1:].count("E")
# リーダーを東にずらしていく
for i in range(1, N):
    ans[i] = ans[i - 1]
    if S[i - 1] == "W":
        ans[i] += 1
    if S[i] == "E":
        ans[i] -= 1
# print("ans : {}".format(ans))
print((min(ans)))

-S = eval(input()) -wc = [0] -ec = [0] -for i in range(N): -    if S[i] == "W": -        wc.append(wc[i] + 1) -        ec.append(ec[i]) -    else: -        wc.append(wc[i]) -        ec.append(ec[i] + 1) -# print("wc : {}, ec : {}".format(wc, ec)) -ans = ec[N] +S = list(eval(input())) +ans = [0] * N +# リーダーより東の東向きの人 +ans[0] = S[1:].count("E") +# リーダーを東にずらしていく -    # W -> cnt, E -> sum - cnt -    tmp = wc[i] + ec[N] - ec[i + 1] -    ans = min(tmp, ans) -print(ans) +    ans[i] = ans[i - 1] +    if S[i - 1] == "W": +        ans[i] += 1 +    if S[i] == "E": +        ans[i] -= 1 +# print("ans : {}".format(ans)) +print((min(ans)))