N = int(eval(input()))

S = eval(input())



l = 0

r = S.count("E", 1, len(S))

ans = l + r

for i in range(1, len(S)):

    if S[i] == "E":

        r -= 1

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

        l += 1



    ans = ans if ans <= l + r else l + r



print(ans)
eval(input())

S = eval(input())



ans = ans_cur = S.count("E")

for c in S:

    if c == "E":

        ans_cur -= 1

    else:

        ans_cur += 1

    ans = ans if ans <= ans_cur else ans_cur

print(ans)
N = int(eval(input()))
S = eval(input())
l = 0
r = S.count("E", 1, len(S))
ans = l + r
for i in range(1, len(S)):
    if S[i] == "E":
        r -= 1
    if S[i - 1] == "W":
        l += 1
    ans = ans if ans <= l + r else l + r
print(ans)

eval(input())
S = eval(input())
ans = ans_cur = S.count("E")
for c in S:
    if c == "E":
        ans_cur -= 1
    else:
        ans_cur += 1
    ans = ans if ans <= ans_cur else ans_cur
print(ans)

-N = int(eval(input())) +eval(input()) -l = 0 -r = S.count("E", 1, len(S)) -ans = l + r -for i in range(1, len(S)): -    if S[i] == "E": -        r -= 1 -    if S[i - 1] == "W": -        l += 1 -    ans = ans if ans <= l + r else l + r +ans = ans_cur = S.count("E") +for c in S: +    if c == "E": +        ans_cur -= 1 +    else: +        ans_cur += 1 +    ans = ans if ans <= ans_cur else ans_cur