n=int(eval(input()))

s=list(eval(input()))

count_east=[0]*n

count_west=[0]*n

counts=[0]*n



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

    if s[i+1]=='E':

        count_east[i]=count_east[i+1]+1

    else:

        count_east[i]=count_east[i+1]

for i in range(1,n):

    if s[i-1]=='W':

        count_west[i]=count_west[i-1]+1

    else:

        count_west[i]=count_west[i-1]

for i in range(n):

    counts[i]=count_east[i]+count_west[i]



print((min(counts)))
n = int(eval(input()))

s = list(eval(input()))



num_E = s.count("E")

num_W = 0

ans = float("inf")



for i in range(n):

    if s[i] == "W":

        ans=min(ans , num_E + num_W)

        num_W += 1

    else:

        num_E -= 1

        ans=min(ans , num_E + num_W)

    

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

n = int(eval(input()))
s = list(eval(input()))
num_E = s.count("E")
num_W = 0
ans = float("inf")
for i in range(n):
    if s[i] == "W":
        ans = min(ans, num_E + num_W)
        num_W += 1
    else:
        num_E -= 1
        ans = min(ans, num_E + num_W)
print(ans)

-count_east = [0] * n -count_west = [0] * n -counts = [0] * n -for i in range(n - 2, -1, -1): -    if s[i + 1] == "E": -        count_east[i] = count_east[i + 1] + 1 +num_E = s.count("E") +num_W = 0 +ans = float("inf") +for i in range(n): +    if s[i] == "W": +        ans = min(ans, num_E + num_W) +        num_W += 1 -        count_east[i] = count_east[i + 1] -for i in range(1, n): -    if s[i - 1] == "W": -        count_west[i] = count_west[i - 1] + 1 -    else: -        count_west[i] = count_west[i - 1] -for i in range(n): -    counts[i] = count_east[i] + count_west[i] -print((min(counts))) +        num_E -= 1 +        ans = min(ans, num_E + num_W) +print(ans)