N = int(eval(input()))

S = eval(input())

left = 0

right = S.count("E")

ans = False

for i in range(N):

    if i > 0 and S[i - 1] == "W":

        left += 1

    if S[i] == "E":

        right -= 1

    if ans is not False:

        ans = min(ans, left + right)

    else:

        ans = left + right

print(ans)

    
N = int(eval(input()))

S = eval(input())

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

ans = num

for i in range(1, N):

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

        num += 1

    if S[i] == "E":

        num -= 1

    ans = min(num, ans)

print(ans)

    
N = int(eval(input()))
S = eval(input())
left = 0
right = S.count("E")
ans = False
for i in range(N):
    if i > 0 and S[i - 1] == "W":
        left += 1
    if S[i] == "E":
        right -= 1
    if ans is not False:
        ans = min(ans, left + right)
    else:
        ans = left + right
print(ans)

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

-left = 0 -right = S.count("E") -ans = False -for i in range(N): -    if i > 0 and S[i - 1] == "W": -        left += 1 +num = S[1:].count("E") +ans = num +for i in range(1, N): +    if S[i - 1] == "W": +        num += 1 -        right -= 1 -    if ans is not False: -        ans = min(ans, left + right) -    else: -        ans = left + right +        num -= 1 +    ans = min(num, ans)