a = int(eval(input()))

ar = list(eval(input()))

wc = 0

ec = ar.count("E")

br = []

for i in range(a):

    if ar[i] == "E":

        ec -= 1

    br.append(ec + wc)

    if ar[i] == "W":

        wc += 1

print((min(br)))
a = int(eval(input()))

ar = eval(input())

n = ar.count("E")

if ar[0] == "E":

    n -= 1

mi = n

for i in range(1,a):

    if ar[i] == "E":

        n -= 1

    if ar[i-1] == "W":

        n += 1

    if n < mi:

        mi = n

print(mi)
a = int(eval(input()))
ar = list(eval(input()))
wc = 0
ec = ar.count("E")
br = []
for i in range(a):
    if ar[i] == "E":
        ec -= 1
    br.append(ec + wc)
    if ar[i] == "W":
        wc += 1
print((min(br)))

a = int(eval(input()))
ar = eval(input())
n = ar.count("E")
if ar[0] == "E":
    n -= 1
mi = n
for i in range(1, a):
    if ar[i] == "E":
        n -= 1
    if ar[i - 1] == "W":
        n += 1
    if n < mi:
        mi = n
print(mi)

-ar = list(eval(input())) -wc = 0 -ec = ar.count("E") -br = [] -for i in range(a): +ar = eval(input()) +n = ar.count("E") +if ar[0] == "E": +    n -= 1 +mi = n +for i in range(1, a): -        ec -= 1 -    br.append(ec + wc) -    if ar[i] == "W": -        wc += 1 -print((min(br))) +        n -= 1 +    if ar[i - 1] == "W": +        n += 1 +    if n < mi: +        mi = n +print(mi)