import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7



def LI(): return list(map(int,input().split()))

def I(): return int(eval(input()))

def LS(): return input().split()

def S(): return eval(input())



def main():

  n=I()

  l=list(S())



  l1=[0]*n

  for i in range(n):

    if l[i]=='E':

      l1[i]+=1



  for i in range(1,n):

    l1[i]+=l1[i-1]



  l2=[]

  for i in range(n):

    l2.append(i+1-l1[i])



  mn=inf

  for i in range(n):

    if l[i]=='W':

      a=l2[i]-1

    else:

      a=l2[i]

    mn=min(mn,l1[-1]-l1[i]+a)



  return mn



print((main()))

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue



sys.setrecursionlimit(10**7)

inf=10**20

mod=10**9+7



def LI(): return list(map(int,input().split()))

def I(): return int(eval(input()))

def LS(): return input().split()

def S(): return eval(input())



def main():

  n=I()

  s=S()



  a=[0]*n

  for i in range(n):

    if s[i]=='W':

      a[i]+=1

    if i<n-1:

      a[i+1]=a[i]



  b=[0]*n

  for i in range(n-1,-1,-1):

    if s[i]=='E':

      b[i]+=1

    if i-1>=0:

      b[i-1]=b[i]



  # print(a)

  # print(b)



  mn=inf

  for i in range(n):

    mn=min(mn,a[i]+b[i]-1)



  return mn



print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def LI():
    return list(map(int, input().split()))


def I():
    return int(eval(input()))


def LS():
    return input().split()


def S():
    return eval(input())


def main():
    n = I()
    l = list(S())
    l1 = [0] * n
    for i in range(n):
        if l[i] == "E":
            l1[i] += 1
    for i in range(1, n):
        l1[i] += l1[i - 1]
    l2 = []
    for i in range(n):
        l2.append(i + 1 - l1[i])
    mn = inf
    for i in range(n):
        if l[i] == "W":
            a = l2[i] - 1
        else:
            a = l2[i]
        mn = min(mn, l1[-1] - l1[i] + a)
    return mn


print((main()))

import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7


def LI():
    return list(map(int, input().split()))


def I():
    return int(eval(input()))


def LS():
    return input().split()


def S():
    return eval(input())


def main():
    n = I()
    s = S()
    a = [0] * n
    for i in range(n):
        if s[i] == "W":
            a[i] += 1
        if i < n - 1:
            a[i + 1] = a[i]
    b = [0] * n
    for i in range(n - 1, -1, -1):
        if s[i] == "E":
            b[i] += 1
        if i - 1 >= 0:
            b[i - 1] = b[i]
    # print(a)
    # print(b)
    mn = inf
    for i in range(n):
        mn = min(mn, a[i] + b[i] - 1)
    return mn


print((main()))

-import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time +import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue -    l = list(S()) -    l1 = [0] * n +    s = S() +    a = [0] * n -        if l[i] == "E": -            l1[i] += 1 -    for i in range(1, n): -        l1[i] += l1[i - 1] -    l2 = [] -    for i in range(n): -        l2.append(i + 1 - l1[i]) +        if s[i] == "W": +            a[i] += 1 +        if i < n - 1: +            a[i + 1] = a[i] +    b = [0] * n +    for i in range(n - 1, -1, -1): +        if s[i] == "E": +            b[i] += 1 +        if i - 1 >= 0: +            b[i - 1] = b[i] +    # print(a) +    # print(b) -        if l[i] == "W": -            a = l2[i] - 1 -        else: -            a = l2[i] -        mn = min(mn, l1[-1] - l1[i] + a) +        mn = min(mn, a[i] + b[i] - 1)