n=int(eval(input()))

s=list(eval(input()))

a=[0]*(n+1)

b=[0]*(n+2)

for i in range(n):

  a[i+1]=a[i]

  b[n-i]=b[n-i+1]

  if s[i]=='W':

    a[i+1]+=1

  if s[n-i-1]=='E':

    b[n-i]+=1

print((min(a[i]+b[i]-1for i in range(1,n+1))))
n,s=open(0)

n=int(n)

a=[0]*(n+1)

b=[0]*(n+2)

for i in range(n):

  a[i+1]=a[i]

  b[n-i]=b[n-i+1]

  if s[i]=='W':

    a[i+1]+=1

  if s[n-i-1]=='E':

    b[n-i]+=1

print((min(a[i]+b[i]-1for i in range(1,n+1))))
n = int(eval(input()))
s = list(eval(input()))
a = [0] * (n + 1)
b = [0] * (n + 2)
for i in range(n):
    a[i + 1] = a[i]
    b[n - i] = b[n - i + 1]
    if s[i] == "W":
        a[i + 1] += 1
    if s[n - i - 1] == "E":
        b[n - i] += 1
print((min(a[i] + b[i] - 1 for i in range(1, n + 1))))

n, s = open(0)
n = int(n)
a = [0] * (n + 1)
b = [0] * (n + 2)
for i in range(n):
    a[i + 1] = a[i]
    b[n - i] = b[n - i + 1]
    if s[i] == "W":
        a[i + 1] += 1
    if s[n - i - 1] == "E":
        b[n - i] += 1
print((min(a[i] + b[i] - 1 for i in range(1, n + 1))))

-n = int(eval(input())) -s = list(eval(input())) +n, s = open(0) +n = int(n)