n = int(eval(input()))

S = eval(input())

ans = n

temp = 0



for i in range(1, n):

    if S[i] =='E':

        temp += 1

ans = min(ans, temp)



for i in range(1, n):

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

        temp += 1

    if S[i] == 'E':

        temp -= 1

    ans = min(ans, temp)        



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

s = eval(input())



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

ans = count

for i in range(1, n):

    if s[i -1] == 'W':

        count += 1

    if s[i] == 'E':

        count -= 1

    ans = min(ans, count)



print(ans)
n = int(eval(input()))
S = eval(input())
ans = n
temp = 0
for i in range(1, n):
    if S[i] == "E":
        temp += 1
ans = min(ans, temp)
for i in range(1, n):
    if S[i - 1] == "W":
        temp += 1
    if S[i] == "E":
        temp -= 1
    ans = min(ans, temp)
print(ans)

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

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