from itertools import accumulate

from operator import add

N = int(eval(input()))

S = eval(input())



cnt_w = [0] * (N+1) # 左からWの数

for i in range(N): # cumsum

  if S[i] == "W":

    cnt_w[i+1] = cnt_w[i] + 1

  else:

    cnt_w[i+1] = cnt_w[i]

  

cnt_e = [0] * (N+1) # 右からEの数

for i in range(N-1, -1, -1):

  if S[i] == "E":

    cnt_e[i] = cnt_e[i+1] + 1

  else:

    cnt_e[i] = cnt_e[i+1]

    

ans = [w+e for w, e in zip(cnt_w, cnt_e)]

print((min(ans)))
from itertools import accumulate



N = int(eval(input()))

S = eval(input())



turn_E = [0] + list(accumulate([s=="W" for s in S[:-1]]))

turn_W = list(reversed(list(accumulate([s=="E" for s in S[:0:-1]])))) + [0]



ans = [e+w for e, w in zip(turn_E, turn_W)]

print((min(ans)))
from itertools import accumulate
from operator import add

N = int(eval(input()))
S = eval(input())
cnt_w = [0] * (N + 1)  # 左からWの数
for i in range(N):  # cumsum
    if S[i] == "W":
        cnt_w[i + 1] = cnt_w[i] + 1
    else:
        cnt_w[i + 1] = cnt_w[i]
cnt_e = [0] * (N + 1)  # 右からEの数
for i in range(N - 1, -1, -1):
    if S[i] == "E":
        cnt_e[i] = cnt_e[i + 1] + 1
    else:
        cnt_e[i] = cnt_e[i + 1]
ans = [w + e for w, e in zip(cnt_w, cnt_e)]
print((min(ans)))

from itertools import accumulate

N = int(eval(input()))
S = eval(input())
turn_E = [0] + list(accumulate([s == "W" for s in S[:-1]]))
turn_W = list(reversed(list(accumulate([s == "E" for s in S[:0:-1]])))) + [0]
ans = [e + w for e, w in zip(turn_E, turn_W)]
print((min(ans)))

-from operator import add -cnt_w = [0] * (N + 1)  # 左からWの数 -for i in range(N):  # cumsum -    if S[i] == "W": -        cnt_w[i + 1] = cnt_w[i] + 1 -    else: -        cnt_w[i + 1] = cnt_w[i] -cnt_e = [0] * (N + 1)  # 右からEの数 -for i in range(N - 1, -1, -1): -    if S[i] == "E": -        cnt_e[i] = cnt_e[i + 1] + 1 -    else: -        cnt_e[i] = cnt_e[i + 1] -ans = [w + e for w, e in zip(cnt_w, cnt_e)] +turn_E = [0] + list(accumulate([s == "W" for s in S[:-1]])) +turn_W = list(reversed(list(accumulate([s == "E" for s in S[:0:-1]])))) + [0] +ans = [e + w for e, w in zip(turn_E, turn_W)]