N = int(eval(input()))

S = eval(input())

left = 0

right = S.count("E")

ans = False

for i in range(N):

    if i > 0:

        left += 1 if S[i - 1] == "W" else 0

    right -= 1 if S[i] == "E" else 0

    if ans is not False:

        ans = min(ans, left + right)

    else:

        ans = left + right

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

-    if i > 0: -        left += 1 if S[i - 1] == "W" else 0 -    right -= 1 if S[i] == "E" else 0 +    if i > 0 and S[i - 1] == "W": +        left += 1 +    if S[i] == "E": +        right -= 1