n=int(eval(input()))

s=list(eval(input()))

n_W,n_E=0,0

l_W,l_E=[0],[0]

for i in s:

    if i=="W":n_W+=1

    else:n_E+=1

    l_W.append(n_W)

    l_E.append(n_E)

ans=10**9+7

for i in range(n):

    tmp=l_W[i]+l_E[-1]-l_E[i+1]

    if tmp<ans:ans=tmp

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

s = str(eval(input()))



lst_ans=[]

num_e= s.count("E")

ans = num_e

for i in range(n):

    if s[i] == "E":ans -= 1

    if i != 0:

        if s[i-1]=="W":ans += 1

    lst_ans.append(ans)

print((min(lst_ans)))
n = int(eval(input()))
s = list(eval(input()))
n_W, n_E = 0, 0
l_W, l_E = [0], [0]
for i in s:
    if i == "W":
        n_W += 1
    else:
        n_E += 1
    l_W.append(n_W)
    l_E.append(n_E)
ans = 10**9 + 7
for i in range(n):
    tmp = l_W[i] + l_E[-1] - l_E[i + 1]
    if tmp < ans:
        ans = tmp
print(ans)

n = int(eval(input()))
s = str(eval(input()))
lst_ans = []
num_e = s.count("E")
ans = num_e
for i in range(n):
    if s[i] == "E":
        ans -= 1
    if i != 0:
        if s[i - 1] == "W":
            ans += 1
    lst_ans.append(ans)
print((min(lst_ans)))

-s = list(eval(input())) -n_W, n_E = 0, 0 -l_W, l_E = [0], [0] -for i in s: -    if i == "W": -        n_W += 1 -    else: -        n_E += 1 -    l_W.append(n_W) -    l_E.append(n_E) -ans = 10**9 + 7 +s = str(eval(input())) +lst_ans = [] +num_e = s.count("E") +ans = num_e -    tmp = l_W[i] + l_E[-1] - l_E[i + 1] -    if tmp < ans: -        ans = tmp -print(ans) +    if s[i] == "E": +        ans -= 1 +    if i != 0: +        if s[i - 1] == "W": +            ans += 1 +    lst_ans.append(ans) +print((min(lst_ans)))