N = int(eval(input()))

S = eval(input())

e,w= [0]*N,[0]*N

for i in range(N-1):      e[i+1] = e[i] + (1 if S[i]=='W' else 0)

for i in range(N-1,0,-1): w[i-1] = w[i] + (1 if S[i]=='E' else 0)

print((min([w[i]+e[i] for i in range(N)])))

N = int(eval(input()))

S = eval(input())

e,w = S.count('E'),0

ans = e+w

for s in S:

  if s == 'E': e -= 1

  else:        w += 1

  ans = min(ans, e+w)

print(ans)

N = int(eval(input()))
S = eval(input())
e, w = [0] * N, [0] * N
for i in range(N - 1):
    e[i + 1] = e[i] + (1 if S[i] == "W" else 0)
for i in range(N - 1, 0, -1):
    w[i - 1] = w[i] + (1 if S[i] == "E" else 0)
print((min([w[i] + e[i] for i in range(N)])))

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

-e, w = [0] * N, [0] * N -for i in range(N - 1): -    e[i + 1] = e[i] + (1 if S[i] == "W" else 0) -for i in range(N - 1, 0, -1): -    w[i - 1] = w[i] + (1 if S[i] == "E" else 0) -print((min([w[i] + e[i] for i in range(N)]))) +e, w = S.count("E"), 0 +ans = e + w +for s in S: +    if s == "E": +        e -= 1 +    else: +        w += 1 +    ans = min(ans, e + w) +print(ans)