n = int(eval(input()))

s = eval(input())

num = [0 for i in range(n)]

w = [0 for i in range(n)]

if s[0] == 'W':

    w[0] = 1

for i in range(1, n):

    if s[i] == 'W':

        w[i] = (w[i-1] + 1)

    else:

        w[i] = w[i-1]

e = [0 for i in range(n)]

if s[n-1] == 'E':

    e[n-1] = 1

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

    if s[n-i] == 'E':

        e[n-i] = (e[n-i+1] + 1)

    else:

        e[n-i] = e[n-i+1]

sol = [0 for i in range(n)]

sol[0] = e[0]

sol[n-1] = w[n-2]

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

    sol[i] = w[i-1] + e[i+1]

print((min(sol)))

n = int(eval(input()))

s = eval(input())

west = [0 for _ in range(n)]

if s[0] == 'W':

    west[0] = 1

for _ in range(1, n):

    if s[_] == 'W':

        west[_] = west[_-1] + 1

    else:

        west[_] = west[_-1]

east = [0 for _ in range(n)]

if s[n-1] == 'E':

    east[n-1] = 1

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

    if s[_] == 'E':

        east[_] = east[_+1] + 1

    else:

        east[_] = east[_+1]

ans = [0 for _ in range(n)]

ans[0] = east[1]

for _ in range(1, n-1):

    ans[_] = west[_-1] + east[_+1]

ans[n-1] = west[n-2]



print((min(ans)))

n = int(eval(input()))
s = eval(input())
num = [0 for i in range(n)]
w = [0 for i in range(n)]
if s[0] == "W":
    w[0] = 1
for i in range(1, n):
    if s[i] == "W":
        w[i] = w[i - 1] + 1
    else:
        w[i] = w[i - 1]
e = [0 for i in range(n)]
if s[n - 1] == "E":
    e[n - 1] = 1
for i in range(2, n + 1):
    if s[n - i] == "E":
        e[n - i] = e[n - i + 1] + 1
    else:
        e[n - i] = e[n - i + 1]
sol = [0 for i in range(n)]
sol[0] = e[0]
sol[n - 1] = w[n - 2]
for i in range(1, n - 1):
    sol[i] = w[i - 1] + e[i + 1]
print((min(sol)))

n = int(eval(input()))
s = eval(input())
west = [0 for _ in range(n)]
if s[0] == "W":
    west[0] = 1
for _ in range(1, n):
    if s[_] == "W":
        west[_] = west[_ - 1] + 1
    else:
        west[_] = west[_ - 1]
east = [0 for _ in range(n)]
if s[n - 1] == "E":
    east[n - 1] = 1
for _ in range(n - 2, -1, -1):
    if s[_] == "E":
        east[_] = east[_ + 1] + 1
    else:
        east[_] = east[_ + 1]
ans = [0 for _ in range(n)]
ans[0] = east[1]
for _ in range(1, n - 1):
    ans[_] = west[_ - 1] + east[_ + 1]
ans[n - 1] = west[n - 2]
print((min(ans)))

-num = [0 for i in range(n)] -w = [0 for i in range(n)] +west = [0 for _ in range(n)] -    w[0] = 1 -for i in range(1, n): -    if s[i] == "W": -        w[i] = w[i - 1] + 1 +    west[0] = 1 +for _ in range(1, n): +    if s[_] == "W": +        west[_] = west[_ - 1] + 1 -        w[i] = w[i - 1] -e = [0 for i in range(n)] +        west[_] = west[_ - 1] +east = [0 for _ in range(n)] -    e[n - 1] = 1 -for i in range(2, n + 1): -    if s[n - i] == "E": -        e[n - i] = e[n - i + 1] + 1 +    east[n - 1] = 1 +for _ in range(n - 2, -1, -1): +    if s[_] == "E": +        east[_] = east[_ + 1] + 1 -        e[n - i] = e[n - i + 1] -sol = [0 for i in range(n)] -sol[0] = e[0] -sol[n - 1] = w[n - 2] -for i in range(1, n - 1): -    sol[i] = w[i - 1] + e[i + 1] -print((min(sol))) +        east[_] = east[_ + 1] +ans = [0 for _ in range(n)] +ans[0] = east[1] +for _ in range(1, n - 1): +    ans[_] = west[_ - 1] + east[_ + 1] +ans[n - 1] = west[n - 2] +print((min(ans)))