import numpy

n = int(eval(input()))

s = eval(input())

a = [0]*n

ans = 10**6

for i in range(n):

    if s[i] == 'W':

        a[i] = 1

res = numpy.cumsum(a)

for i in range(n):

    x = res[i]-str(a[i]).count('1')

    y = n-i-1-(res[n-1]-res[i])

    ans = min(ans,x+y)

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

s = eval(input())

a = [0]*n

res = [0]*n

ans = 10**6

for i in range(n):

    if s[i] == 'W':

        a[i] = 1

res[0] = a[0]

for i in range(n-1):

    res[i+1] = res[i] + a[i+1]

for i in range(n):

    x = res[i]-str(a[i]).count('1')

    y = n-i-1-(res[n-1]-res[i])

    ans = min(ans,x+y)

print(ans)
import numpy

n = int(eval(input()))
s = eval(input())
a = [0] * n
ans = 10**6
for i in range(n):
    if s[i] == "W":
        a[i] = 1
res = numpy.cumsum(a)
for i in range(n):
    x = res[i] - str(a[i]).count("1")
    y = n - i - 1 - (res[n - 1] - res[i])
    ans = min(ans, x + y)
print(ans)

n = int(eval(input()))
s = eval(input())
a = [0] * n
res = [0] * n
ans = 10**6
for i in range(n):
    if s[i] == "W":
        a[i] = 1
res[0] = a[0]
for i in range(n - 1):
    res[i + 1] = res[i] + a[i + 1]
for i in range(n):
    x = res[i] - str(a[i]).count("1")
    y = n - i - 1 - (res[n - 1] - res[i])
    ans = min(ans, x + y)
print(ans)

-import numpy - +res = [0] * n -res = numpy.cumsum(a) +res[0] = a[0] +for i in range(n - 1): +    res[i + 1] = res[i] + a[i + 1]