n = int(eval(input()))

s = eval(input())

total = s[1:].count('E')

ans = total

for i in range(n-1):

    if s[i]=='W':

        total += 1

    if s[i+1]=='E':

        total -= 1

    ans = min(ans, total)

print(ans)

n = int(eval(input()))

s = eval(input())

total = s[1:].count('E')

ans = total

for i in range(n-1):

    if s[i]=='W':

        total += 1

    if s[i+1]=='E':

        total -= 1

    if ans>total:

      ans = total

print(ans)

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

n = int(eval(input()))
s = eval(input())
total = s[1:].count("E")
ans = total
for i in range(n - 1):
    if s[i] == "W":
        total += 1
    if s[i + 1] == "E":
        total -= 1
    if ans > total:
        ans = total
print(ans)

-    ans = min(ans, total) +    if ans > total: +        ans = total