#!/usr/bin/env python3

n = int(eval(input()))

s = eval(input())

e = [0]

w = [0]

for i in s:

    e.append(e[-1] + (i == "E"))

    w.append(w[-1] + (i == "W"))

ans = 10**6

for i in range(n):

    ans = min(ans, w[i] + e[-1] - e[i + 1])

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)

#!/usr/bin/env python3
n = int(eval(input()))
s = eval(input())
e = [0]
w = [0]
for i in s:
    e.append(e[-1] + (i == "E"))
    w.append(w[-1] + (i == "W"))
ans = 10**6
for i in range(n):
    ans = min(ans, w[i] + e[-1] - e[i + 1])
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)

-e = [0] -w = [0] +w = 0 +e = s.count("E") +ans = 10**6 -    e.append(e[-1] + (i == "E")) -    w.append(w[-1] + (i == "W")) -ans = 10**6 -for i in range(n): -    ans = min(ans, w[i] + e[-1] - e[i + 1]) +    e -= i == "E" +    ans = min(ans, e + w) +    w += i == "W"