#!/usr/bin/env python3

n = int(eval(input()))

s = eval(input())

w = 0

e = s.count("E")

ans = 10**6

for i in s:

    e -= i == "E"

    ans = min(ans, e + w)

    w += i == "W"

print(ans)

n = int(eval(input()))

s = eval(input())

e = s.count("E")

ans = 10**6

for i in s:

    e -= i == "E"

    ans = min(ans, e)

    e += i == "W"

print(ans)

#!/usr/bin/env python3
n = int(eval(input()))
s = eval(input())
w = 0
e = s.count("E")
ans = 10**6
for i in s:
    e -= i == "E"
    ans = min(ans, e + w)
    w += i == "W"
print(ans)

n = int(eval(input()))
s = eval(input())
e = s.count("E")
ans = 10**6
for i in s:
    e -= i == "E"
    ans = min(ans, e)
    e += i == "W"
print(ans)

-#!/usr/bin/env python3 -w = 0 -    ans = min(ans, e + w) -    w += i == "W" +    ans = min(ans, e) +    e += i == "W"