N=int(eval(input()))

S=eval(input())



import collections

tw=S.count('W')

te=S.count('E')



ans=float('inf')

cw=[0,0]

ce=[tw,te]

#print(cw,ce)

for i in S:

    if i=='W':

        ce[0]-=1

        ans=min(ans,cw[0]+ce[1])

        #print(cw,ce,cw[0]+ce[1])

        cw[0]+=1

    else:

        ce[1]-=1

        ans=min(ans,cw[0]+ce[1])

        #print(cw,ce,cw[0]+ce[1])

        cw[1]+=1

    

print(ans)
eval(input())

S=eval(input())



ans=float('inf')

cw=0

ce=S.count('E')



for i in S:

 if i=='W':

   ans=min(ans,cw+ce)

   cw+=1

 else:

   ce-=1

   ans=min(ans,cw+ce)

print(ans)
N = int(eval(input()))
S = eval(input())
import collections

tw = S.count("W")
te = S.count("E")
ans = float("inf")
cw = [0, 0]
ce = [tw, te]
# print(cw,ce)
for i in S:
    if i == "W":
        ce[0] -= 1
        ans = min(ans, cw[0] + ce[1])
        # print(cw,ce,cw[0]+ce[1])
        cw[0] += 1
    else:
        ce[1] -= 1
        ans = min(ans, cw[0] + ce[1])
        # print(cw,ce,cw[0]+ce[1])
        cw[1] += 1
print(ans)

eval(input())
S = eval(input())
ans = float("inf")
cw = 0
ce = S.count("E")
for i in S:
    if i == "W":
        ans = min(ans, cw + ce)
        cw += 1
    else:
        ce -= 1
        ans = min(ans, cw + ce)
print(ans)

-N = int(eval(input())) +eval(input()) -import collections - -tw = S.count("W") -te = S.count("E") -cw = [0, 0] -ce = [tw, te] -# print(cw,ce) +cw = 0 +ce = S.count("E") -        ce[0] -= 1 -        ans = min(ans, cw[0] + ce[1]) -        # print(cw,ce,cw[0]+ce[1]) -        cw[0] += 1 +        ans = min(ans, cw + ce) +        cw += 1 -        ce[1] -= 1 -        ans = min(ans, cw[0] + ce[1]) -        # print(cw,ce,cw[0]+ce[1]) -        cw[1] += 1 +        ce -= 1 +        ans = min(ans, cw + ce)