N = int(eval(input()))

S = eval(input())

l = 0

r = S[1:N].count('E')

ans = l+r



for n in range(1,N):

  if S[n-1]=="W":

    l+=1

  if S[n]=="E":

    r-=1

  ans=min(ans,l+r)



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

S = eval(input())

a = S.count("E")

c = a 



for s in S:

  if s=="E":

    c-=1

  else:

    c+=1

  a=min(a,c)



print(a)
N = int(eval(input()))
S = eval(input())
l = 0
r = S[1:N].count("E")
ans = l + r
for n in range(1, N):
    if S[n - 1] == "W":
        l += 1
    if S[n] == "E":
        r -= 1
    ans = min(ans, l + r)
print(ans)

N = int(eval(input()))
S = eval(input())
a = S.count("E")
c = a
for s in S:
    if s == "E":
        c -= 1
    else:
        c += 1
    a = min(a, c)
print(a)

-l = 0 -r = S[1:N].count("E") -ans = l + r -for n in range(1, N): -    if S[n - 1] == "W": -        l += 1 -    if S[n] == "E": -        r -= 1 -    ans = min(ans, l + r) -print(ans) +a = S.count("E") +c = a +for s in S: +    if s == "E": +        c -= 1 +    else: +        c += 1 +    a = min(a, c) +print(a)