N = int(eval(input()))

S = eval(input())

e_count = S.count('E')

w_count = 0

ans = e_count

for s in S:

    if s == 'E':

        e_count -= 1

    else:

        w_count += 1

    ans = min(ans, e_count + w_count)

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

S = eval(input())

e_count = S.count('E')

w_count = 0

ans = e_count

for s in S:

    if s == 'E':

        e_count -= 1

    else:

        w_count += 1

    if e_count + w_count < ans:

        ans = e_count + w_count

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

N = int(eval(input()))
S = eval(input())
e_count = S.count("E")
w_count = 0
ans = e_count
for s in S:
    if s == "E":
        e_count -= 1
    else:
        w_count += 1
    if e_count + w_count < ans:
        ans = e_count + w_count
print(ans)

-    ans = min(ans, e_count + w_count) +    if e_count + w_count < ans: +        ans = e_count + w_count