n = int(eval(input()))

s = eval(input())



a, b = [], []

for i in range(n):

    if s[i] == 'W':

        a.append(1)

        b.append(0)

    else:

        a.append(0)

        b.append(1)        

        

import itertools

accum_a = [0] + list(itertools.accumulate(a))

accum_b = list(itertools.accumulate(b))



ans = float('inf')

for i in range(n):

    ans = min(ans, accum_a[i] + abs((accum_b[-1] - accum_b[i])))

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

s = eval(input())



chg = [0]*n



cnt = 0

for i in range(1, n):  # 左側から

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

        cnt += 1

    chg[i] += cnt



cnt = 0

for i in range(1, n):  # 右側から

    if s[-i] == 'E':

        cnt += 1

    chg[-1-i] += cnt

    

print((min(chg)))
n = int(eval(input()))
s = eval(input())
a, b = [], []
for i in range(n):
    if s[i] == "W":
        a.append(1)
        b.append(0)
    else:
        a.append(0)
        b.append(1)
import itertools

accum_a = [0] + list(itertools.accumulate(a))
accum_b = list(itertools.accumulate(b))
ans = float("inf")
for i in range(n):
    ans = min(ans, accum_a[i] + abs((accum_b[-1] - accum_b[i])))
print(ans)

n = int(eval(input()))
s = eval(input())
chg = [0] * n
cnt = 0
for i in range(1, n):  # 左側から
    if s[i - 1] == "W":
        cnt += 1
    chg[i] += cnt
cnt = 0
for i in range(1, n):  # 右側から
    if s[-i] == "E":
        cnt += 1
    chg[-1 - i] += cnt
print((min(chg)))

-a, b = [], [] -for i in range(n): -    if s[i] == "W": -        a.append(1) -        b.append(0) -    else: -        a.append(0) -        b.append(1) -import itertools - -accum_a = [0] + list(itertools.accumulate(a)) -accum_b = list(itertools.accumulate(b)) -ans = float("inf") -for i in range(n): -    ans = min(ans, accum_a[i] + abs((accum_b[-1] - accum_b[i]))) -print(ans) +chg = [0] * n +cnt = 0 +for i in range(1, n):  # 左側から +    if s[i - 1] == "W": +        cnt += 1 +    chg[i] += cnt +cnt = 0 +for i in range(1, n):  # 右側から +    if s[-i] == "E": +        cnt += 1 +    chg[-1 - i] += cnt +print((min(chg)))