n = int(eval(input()))

s = eval(input())



w = [0]*n

e = [0]*n



for i in range(n):

  if s[i] == "W": w[i] += 1

  else: e[i] += 1

  if i != n-1:

    w[i+1] = w[i]

    e[i+1] = e[i]



ans = e[-1]-e[0]

for i in range(1,n):

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

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

s = eval(input())



w = [0]*n

e = [0]*n

if s[0] == "W": w[0] = 1

else: e[0] = 1

for i in range(1,n):

  if s[i] == "W":

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

    e[i] = e[i-1]

  else:

    w[i] = w[i-1]

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



ans = float("inf")

for i in range(n):

  t = 0

  if i != 0: t += w[i-1]

  if i != n-1: t += e[-1] - e[i]

  if t < ans: ans = t

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

n = int(eval(input()))
s = eval(input())
w = [0] * n
e = [0] * n
if s[0] == "W":
    w[0] = 1
else:
    e[0] = 1
for i in range(1, n):
    if s[i] == "W":
        w[i] = w[i - 1] + 1
        e[i] = e[i - 1]
    else:
        w[i] = w[i - 1]
        e[i] = e[i - 1] + 1
ans = float("inf")
for i in range(n):
    t = 0
    if i != 0:
        t += w[i - 1]
    if i != n - 1:
        t += e[-1] - e[i]
    if t < ans:
        ans = t
print(ans)

+if s[0] == "W": +    w[0] = 1 +else: +    e[0] = 1 +for i in range(1, n): +    if s[i] == "W": +        w[i] = w[i - 1] + 1 +        e[i] = e[i - 1] +    else: +        w[i] = w[i - 1] +        e[i] = e[i - 1] + 1 +ans = float("inf") -    if s[i] == "W": -        w[i] += 1 -    else: -        e[i] += 1 +    t = 0 +    if i != 0: +        t += w[i - 1] -        w[i + 1] = w[i] -        e[i + 1] = e[i] -ans = e[-1] - e[0] -for i in range(1, n): -    ans = min(ans, w[i - 1] + e[-1] - e[i]) +        t += e[-1] - e[i] +    if t < ans: +        ans = t