N = int(eval(input()))

S = eval(input())

E = S.count('E')

res = E

W = 0

for s in S:

    if s == 'E':

        E -= 1

    else:

        W += 1

    res = min(res,W+E)

print(res)
N = int(eval(input()))

S = eval(input())

E = S.count('E')

W = 0

res = E

for s in S:

    if s == 'E':

        E -= 1

    else:

        W += 1

    res = min(res,W+E)

print(res)
N = int(eval(input()))
S = eval(input())
E = S.count("E")
res = E
W = 0
for s in S:
    if s == "E":
        E -= 1
    else:
        W += 1
    res = min(res, W + E)
print(res)

N = int(eval(input()))
S = eval(input())
E = S.count("E")
W = 0
res = E
for s in S:
    if s == "E":
        E -= 1
    else:
        W += 1
    res = min(res, W + E)
print(res)

+W = 0 -W = 0