import numpy as np

N = int(eval(input()))

S = np.array(list(eval(input())))

n = []

for i in range(N):

    if S[i] == 'E':

        S[i] = 1

    else:

        S[i] = 0

S = np.array(S, dtype=int)

S = np.cumsum(S)

last = S[N-1]

n.append(last-S[0])

for i in range(1, N):

    ls = i - S[i-1]

    rs = last - S[i]

    n.append(ls+rs)

print((min(n)))

N = int(eval(input()))

S = list(eval(input()))

e = [0]*(N+1)

w = [0]*(N+1)

if S[0] == 'E':

    e[0] += 1

else:

    w[0] += 1

for i in range(1, N):

    if S[i] == 'E':

        e[i] += e[i-1] + 1

        w[i] += w[i-1]

    else:

        e[i] += e[i-1]

        w[i] += w[i-1] + 1

        

ans = float('inf')

for i in range(N):

    tmp = w[i-1] + e[N-1] - e[i]

    ans = min(ans, tmp)

print(ans)
import numpy as np

N = int(eval(input()))
S = np.array(list(eval(input())))
n = []
for i in range(N):
    if S[i] == "E":
        S[i] = 1
    else:
        S[i] = 0
S = np.array(S, dtype=int)
S = np.cumsum(S)
last = S[N - 1]
n.append(last - S[0])
for i in range(1, N):
    ls = i - S[i - 1]
    rs = last - S[i]
    n.append(ls + rs)
print((min(n)))

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

-import numpy as np - -S = np.array(list(eval(input()))) -n = [] +S = list(eval(input())) +e = [0] * (N + 1) +w = [0] * (N + 1) +if S[0] == "E": +    e[0] += 1 +else: +    w[0] += 1 +for i in range(1, N): +    if S[i] == "E": +        e[i] += e[i - 1] + 1 +        w[i] += w[i - 1] +    else: +        e[i] += e[i - 1] +        w[i] += w[i - 1] + 1 +ans = float("inf") -    if S[i] == "E": -        S[i] = 1 -    else: -        S[i] = 0 -S = np.array(S, dtype=int) -S = np.cumsum(S) -last = S[N - 1] -n.append(last - S[0]) -for i in range(1, N): -    ls = i - S[i - 1] -    rs = last - S[i] -    n.append(ls + rs) -print((min(n))) +    tmp = w[i - 1] + e[N - 1] - e[i] +    ans = min(ans, tmp) +print(ans)