N=int(eval(input()))

S=eval(input())

 

count=S[1:].count("E")

mincount=count

 

for i in range(1,N):

    if S[i]=="E":

        count-=1

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

        count+=1

 

 

    mincount=min(count,mincount)

print(mincount)

n=int(eval(input()))

s=list(eval(input()))

ls=[0 if i=='W' else 1 for i in s]

a=sum(ls)

#print(a)

l=[0]*n

for i in range(n):

    if ls[i]==1:

        a-=1

        l[i]=a

    elif ls[i]==0:

        a+=1

        l[i]=a-1

print((min(l)))
N = int(eval(input()))
S = eval(input())
count = S[1:].count("E")
mincount = count
for i in range(1, N):
    if S[i] == "E":
        count -= 1
    if S[i - 1] == "W":
        count += 1
    mincount = min(count, mincount)
print(mincount)

n = int(eval(input()))
s = list(eval(input()))
ls = [0 if i == "W" else 1 for i in s]
a = sum(ls)
# print(a)
l = [0] * n
for i in range(n):
    if ls[i] == 1:
        a -= 1
        l[i] = a
    elif ls[i] == 0:
        a += 1
        l[i] = a - 1
print((min(l)))

-N = int(eval(input())) -S = eval(input()) -count = S[1:].count("E") -mincount = count -for i in range(1, N): -    if S[i] == "E": -        count -= 1 -    if S[i - 1] == "W": -        count += 1 -    mincount = min(count, mincount) -print(mincount) +n = int(eval(input())) +s = list(eval(input())) +ls = [0 if i == "W" else 1 for i in s] +a = sum(ls) +# print(a) +l = [0] * n +for i in range(n): +    if ls[i] == 1: +        a -= 1 +        l[i] = a +    elif ls[i] == 0: +        a += 1 +        l[i] = a - 1 +print((min(l)))