n = int(eval(input()))

s = eval(input())

east = s.count('E')

ans = east

for i in range(n):

  if s[i]=='E': east-=1

  if i>=1:

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

  ans = min(ans,east)

print(ans)
n = int(eval(input()))

s = eval(input())

e = s.count('E')

w = s.count('W')

ans = 1000000

e_counter = 0

w_counter = 0

for i in range(len(s)):

    if s[i] == 'E':

        e_counter += 1

    else:

        w_counter += 1

    d = w_counter

    if s[i] == 'W':

        d -= 1

    ans1 = d + (e - e_counter)

    ans = min(ans1, ans)

print(ans)
n = int(eval(input()))
s = eval(input())
east = s.count("E")
ans = east
for i in range(n):
    if s[i] == "E":
        east -= 1
    if i >= 1:
        if s[i - 1] == "W":
            east += 1
    ans = min(ans, east)
print(ans)

n = int(eval(input()))
s = eval(input())
e = s.count("E")
w = s.count("W")
ans = 1000000
e_counter = 0
w_counter = 0
for i in range(len(s)):
    if s[i] == "E":
        e_counter += 1
    else:
        w_counter += 1
    d = w_counter
    if s[i] == "W":
        d -= 1
    ans1 = d + (e - e_counter)
    ans = min(ans1, ans)
print(ans)

-east = s.count("E") -ans = east -for i in range(n): +e = s.count("E") +w = s.count("W") +ans = 1000000 +e_counter = 0 +w_counter = 0 +for i in range(len(s)): -        east -= 1 -    if i >= 1: -        if s[i - 1] == "W": -            east += 1 -    ans = min(ans, east) +        e_counter += 1 +    else: +        w_counter += 1 +    d = w_counter +    if s[i] == "W": +        d -= 1 +    ans1 = d + (e - e_counter) +    ans = min(ans1, ans)