eval(input())

S = eval(input())

res = cnt = S.count('E')

for c in S:

    cnt -= c == 'E'

    res = min(res, cnt)

    cnt += c == 'W'

print(res)
eval(input())

S = eval(input())

res = cnt = S.count('E')

for c in S:

    if c == 'E':

        cnt -= 1

        res = min(res, cnt)

    else:

        cnt += 1

print(res)
eval(input())
S = eval(input())
res = cnt = S.count("E")
for c in S:
    cnt -= c == "E"
    res = min(res, cnt)
    cnt += c == "W"
print(res)

eval(input())
S = eval(input())
res = cnt = S.count("E")
for c in S:
    if c == "E":
        cnt -= 1
        res = min(res, cnt)
    else:
        cnt += 1
print(res)

-    cnt -= c == "E" -    res = min(res, cnt) -    cnt += c == "W" +    if c == "E": +        cnt -= 1 +        res = min(res, cnt) +    else: +        cnt += 1