# E = 右向き, W = 左向き

n = int(eval(input()))

s = eval(input())

we = s.count('E')

ww = s.count('W')

ew = 0

ee = 0

ans = 3 * (10 ** 5)

for i in range(n):

    if s[i] == 'W':

        ww -= 1

    else:

        we -= 1

    ans = min(ans,we+ew)

    if s[i] == 'W':

        ew += 1

    else:

        ee += 1

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

s = eval(input())

e = s.count('E')

w = 0

ans = 3 * (10 ** 5)

for i in s:

    if i == 'E':

        e -= 1

    ans = min(ans,e + w)

    if i == 'W':

        w += 1

print(ans)
# E = 右向き, W = 左向き
n = int(eval(input()))
s = eval(input())
we = s.count("E")
ww = s.count("W")
ew = 0
ee = 0
ans = 3 * (10**5)
for i in range(n):
    if s[i] == "W":
        ww -= 1
    else:
        we -= 1
    ans = min(ans, we + ew)
    if s[i] == "W":
        ew += 1
    else:
        ee += 1
print(ans)

n = int(eval(input()))
s = eval(input())
e = s.count("E")
w = 0
ans = 3 * (10**5)
for i in s:
    if i == "E":
        e -= 1
    ans = min(ans, e + w)
    if i == "W":
        w += 1
print(ans)

-# E = 右向き, W = 左向き -we = s.count("E") -ww = s.count("W") -ew = 0 -ee = 0 +e = s.count("E") +w = 0 -for i in range(n): -    if s[i] == "W": -        ww -= 1 -    else: -        we -= 1 -    ans = min(ans, we + ew) -    if s[i] == "W": -        ew += 1 -    else: -        ee += 1 +for i in s: +    if i == "E": +        e -= 1 +    ans = min(ans, e + w) +    if i == "W": +        w += 1