"""

WEEWW

<>><<

01100

10100

01000

10000

10010



下記の和

1. リーダーより左にいるWの数

2. リーダーより右にいるEの数

"""



N = int(eval(input()))

S = eval(input())

# 1.

cntW = 0

W_num = [0]*N

for i,s in enumerate(S):

    if s == "W":

        cntW += 1

    W_num[i] = cntW

        

# 2. 

cntE = 0

E_num = [0]*N

for i,s in enumerate(S[::-1]):

    if s == "E":

        cntE +=1 

    E_num[i] = cntE

E_num = E_num[::-1]



ans = 10**10

for e,w in zip(E_num, W_num):

    cnt = e + w - 1

    ans = min(cnt, ans)

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

S = eval(input())



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

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

for i in range(N):

    if S[i] == "W":

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

    else:

        cnt_w[i+1] = cnt_w[i]

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]



# print("W",cnt_w)

# print("E",cnt_e)

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

print((min(ans)))
"""
WEEWW
<>><<
01100
10100
01000
10000
10010
下記の和
1. リーダーより左にいるWの数
2. リーダーより右にいるEの数
"""
N = int(eval(input()))
S = eval(input())
# 1.
cntW = 0
W_num = [0] * N
for i, s in enumerate(S):
    if s == "W":
        cntW += 1
    W_num[i] = cntW
# 2.
cntE = 0
E_num = [0] * N
for i, s in enumerate(S[::-1]):
    if s == "E":
        cntE += 1
    E_num[i] = cntE
E_num = E_num[::-1]
ans = 10**10
for e, w in zip(E_num, W_num):
    cnt = e + w - 1
    ans = min(cnt, ans)
print(ans)

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

-""" -WEEWW -<>><< -01100 -10100 -01000 -10000 -10010 -下記の和 -1. リーダーより左にいるWの数 -2. リーダーより右にいるEの数 -""" -# 1. -cntW = 0 -W_num = [0] * N -for i, s in enumerate(S): -    if s == "W": -        cntW += 1 -    W_num[i] = cntW -# 2. -cntE = 0 -E_num = [0] * N -for i, s in enumerate(S[::-1]): -    if s == "E": -        cntE += 1 -    E_num[i] = cntE -E_num = E_num[::-1] -ans = 10**10 -for e, w in zip(E_num, W_num): -    cnt = e + w - 1 -    ans = min(cnt, ans) -print(ans) +cnt_w = [0] * (N + 1)  # 左からWの数 +cnt_e = [0] * (N + 1)  # 右からEの数 +for i in range(N): +    if S[i] == "W": +        cnt_w[i + 1] = cnt_w[i] + 1 +    else: +        cnt_w[i + 1] = cnt_w[i] +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] +# print("W",cnt_w) +# print("E",cnt_e) +ans = [w + e for w, e in zip(cnt_w, cnt_e)] +print((min(ans)))