N=int(eval(input()))

S=eval(input())



tmp=0

w=[]

for s in S:

  if s=='W': tmp+=1

  w.append(tmp)



tmp=0

e=[]

for s in S[::-1]:

  if s=='E': tmp+=1

  e.append(tmp)

e=e[::-1]



ans=[]

for i in range(N):

  ans.append(w[i]+e[i]-1)

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

S=eval(input())



def cumsum_arr(s, w):

  arr=[]

  cnt=0

  for s_ in s:

    if s_==w: cnt+=1

    arr.append(cnt)

  return arr



w=cumsum_arr(S,      'W')

e=cumsum_arr(S[::-1],'E')

e=e[::-1]

ans=[w[i]+e[i]-1 for i in range(N)]

print((min(ans)))
N = int(eval(input()))
S = eval(input())
tmp = 0
w = []
for s in S:
    if s == "W":
        tmp += 1
    w.append(tmp)
tmp = 0
e = []
for s in S[::-1]:
    if s == "E":
        tmp += 1
    e.append(tmp)
e = e[::-1]
ans = []
for i in range(N):
    ans.append(w[i] + e[i] - 1)
print((min(ans)))

N = int(eval(input()))
S = eval(input())


def cumsum_arr(s, w):
    arr = []
    cnt = 0
    for s_ in s:
        if s_ == w:
            cnt += 1
        arr.append(cnt)
    return arr


w = cumsum_arr(S, "W")
e = cumsum_arr(S[::-1], "E")
e = e[::-1]
ans = [w[i] + e[i] - 1 for i in range(N)]
print((min(ans)))

-tmp = 0 -w = [] -for s in S: -    if s == "W": -        tmp += 1 -    w.append(tmp) -tmp = 0 -e = [] -for s in S[::-1]: -    if s == "E": -        tmp += 1 -    e.append(tmp) + + +def cumsum_arr(s, w): +    arr = [] +    cnt = 0 +    for s_ in s: +        if s_ == w: +            cnt += 1 +        arr.append(cnt) +    return arr + + +w = cumsum_arr(S, "W") +e = cumsum_arr(S[::-1], "E") -ans = [] -for i in range(N): -    ans.append(w[i] + e[i] - 1) +ans = [w[i] + e[i] - 1 for i in range(N)]