n = int(eval(input()))

s = eval(input())

all_w = s.count('W')

all_e = s.count('E')

left_w = 0

right_e = all_e

ans = left_w + right_e

for i in range(n):

    if s[i] == 'E':

        right_e -= 1

    ans = min(ans, left_w + right_e)

    if s[i] == 'W':

        left_w += 1

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

s = eval(input())

left_w = 0

right_e = s.count('E')

ans = left_w + right_e

for i in range(n):

    if s[i] == 'E':

        right_e -= 1

    ans = min(ans, left_w + right_e)

    if s[i] == 'W':

        left_w += 1

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

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

-all_w = s.count("W") -all_e = s.count("E") -right_e = all_e +right_e = s.count("E")