n = int(eval(input()))

s = eval(input())



c = list(s)



lw = 0

le = 0

rw = s[1:].count("W")

re = s[1:].count("E")



ans = lw + re



for i in range(1,n):

    lw = lw + bool(c[i-1] == "W")

    le = le + bool(c[i-1] == "E")

    rw = rw - bool(c[i] == "W")

    re = re - bool(c[i] == "E")

    

    ans = min(ans, lw+re)

    

print(ans)
import sys

stdin = sys.stdin



sys.setrecursionlimit(10**5)



def li(): return list(map(int, stdin.readline().split()))

def li_(): return [int(x)-1 for x in stdin.readline().split()]

def lf(): return list(map(float, stdin.readline().split()))

def ls(): return stdin.readline().split()

def ns(): return stdin.readline().rstrip()

def lc(): return list(ns())

def ni(): return int(stdin.readline())

def nf(): return float(stdin.readline())



n = ni()

s = lc()



le = 0

lw = 0

re = s[1:].count("E")

rw = s[1:].count("W")



ans = lw + re



for i in range(1,n):

    if s[i-1] == "E":

        le += 1

    else:

        lw += 1

        

    if s[i] == "E":

        re -= 1

    else:

        rw -= 1

        

    ans = min(ans, lw+re)



print(ans)
n = int(eval(input()))
s = eval(input())
c = list(s)
lw = 0
le = 0
rw = s[1:].count("W")
re = s[1:].count("E")
ans = lw + re
for i in range(1, n):
    lw = lw + bool(c[i - 1] == "W")
    le = le + bool(c[i - 1] == "E")
    rw = rw - bool(c[i] == "W")
    re = re - bool(c[i] == "E")
    ans = min(ans, lw + re)
print(ans)

import sys

stdin = sys.stdin
sys.setrecursionlimit(10**5)


def li():
    return list(map(int, stdin.readline().split()))


def li_():
    return [int(x) - 1 for x in stdin.readline().split()]


def lf():
    return list(map(float, stdin.readline().split()))


def ls():
    return stdin.readline().split()


def ns():
    return stdin.readline().rstrip()


def lc():
    return list(ns())


def ni():
    return int(stdin.readline())


def nf():
    return float(stdin.readline())


n = ni()
s = lc()
le = 0
lw = 0
re = s[1:].count("E")
rw = s[1:].count("W")
ans = lw + re
for i in range(1, n):
    if s[i - 1] == "E":
        le += 1
    else:
        lw += 1
    if s[i] == "E":
        re -= 1
    else:
        rw -= 1
    ans = min(ans, lw + re)
print(ans)

-n = int(eval(input())) -s = eval(input()) -c = list(s) +import sys + +stdin = sys.stdin +sys.setrecursionlimit(10**5) + + +def li(): +    return list(map(int, stdin.readline().split())) + + +def li_(): +    return [int(x) - 1 for x in stdin.readline().split()] + + +def lf(): +    return list(map(float, stdin.readline().split())) + + +def ls(): +    return stdin.readline().split() + + +def ns(): +    return stdin.readline().rstrip() + + +def lc(): +    return list(ns()) + + +def ni(): +    return int(stdin.readline()) + + +def nf(): +    return float(stdin.readline()) + + +n = ni() +s = lc() +le = 0 -le = 0 +re = s[1:].count("E") -re = s[1:].count("E") -    lw = lw + bool(c[i - 1] == "W") -    le = le + bool(c[i - 1] == "E") -    rw = rw - bool(c[i] == "W") -    re = re - bool(c[i] == "E") +    if s[i - 1] == "E": +        le += 1 +    else: +        lw += 1 +    if s[i] == "E": +        re -= 1 +    else: +        rw -= 1