n=int(eval(input()))

s=eval(input())

ss=s[::-1]

ans=10**7

front_bucket=[0,0]

back_bucket=[0,0]



for i in range(n):

  if s[i]=="E":

    front_bucket[0]+=1

  else:

    front_bucket[1]+=1



for i in range(n):

  if ss[i]=="E":

    front_bucket[0]-=1

    ans=min(ans, front_bucket[1]+back_bucket[0])

    back_bucket[0]+=1



  else:

    front_bucket[1]-=1    

    ans=min(ans, front_bucket[1]+back_bucket[0])

    back_bucket[1]+=1



print(ans)


n=int(eval(input()))

s=eval(input())



E = [0 for i in range(n)]

W = [0 for i in range(n)]



for i in range(n):

    if s[i] == "E":

        E[i] = 1

    else:

        W[i] = 1

for i in range(n-1):

    W[i+1] += W[i]

    E[-i-2] += E[-i-1]



ans = float("inf")

for i in range(n):

    if i == 0:

        ans = min(ans, E[i+1])

    elif i == n-1:

        ans = min(ans, W[i-1])

    else:

        ans = min(ans, E[i+1]+W[i-1])



print(ans)

#print(E)

#print(W)
n = int(eval(input()))
s = eval(input())
ss = s[::-1]
ans = 10**7
front_bucket = [0, 0]
back_bucket = [0, 0]
for i in range(n):
    if s[i] == "E":
        front_bucket[0] += 1
    else:
        front_bucket[1] += 1
for i in range(n):
    if ss[i] == "E":
        front_bucket[0] -= 1
        ans = min(ans, front_bucket[1] + back_bucket[0])
        back_bucket[0] += 1
    else:
        front_bucket[1] -= 1
        ans = min(ans, front_bucket[1] + back_bucket[0])
        back_bucket[1] += 1
print(ans)

n = int(eval(input()))
s = eval(input())
E = [0 for i in range(n)]
W = [0 for i in range(n)]
for i in range(n):
    if s[i] == "E":
        E[i] = 1
    else:
        W[i] = 1
for i in range(n - 1):
    W[i + 1] += W[i]
    E[-i - 2] += E[-i - 1]
ans = float("inf")
for i in range(n):
    if i == 0:
        ans = min(ans, E[i + 1])
    elif i == n - 1:
        ans = min(ans, W[i - 1])
    else:
        ans = min(ans, E[i + 1] + W[i - 1])
print(ans)
# print(E)
# print(W)

-ss = s[::-1] -ans = 10**7 -front_bucket = [0, 0] -back_bucket = [0, 0] +E = [0 for i in range(n)] +W = [0 for i in range(n)] -        front_bucket[0] += 1 +        E[i] = 1 -        front_bucket[1] += 1 +        W[i] = 1 +for i in range(n - 1): +    W[i + 1] += W[i] +    E[-i - 2] += E[-i - 1] +ans = float("inf") -    if ss[i] == "E": -        front_bucket[0] -= 1 -        ans = min(ans, front_bucket[1] + back_bucket[0]) -        back_bucket[0] += 1 +    if i == 0: +        ans = min(ans, E[i + 1]) +    elif i == n - 1: +        ans = min(ans, W[i - 1]) -        front_bucket[1] -= 1 -        ans = min(ans, front_bucket[1] + back_bucket[0]) -        back_bucket[1] += 1 +        ans = min(ans, E[i + 1] + W[i - 1]) +# print(E) +# print(W)