n = int(eval(input()))

s = eval(input())

ecnt = [0]*n

wcnt = [0]*n

res = 0

for i in range(1,n):

    #ecnt

    if s[i-1] == 'E':res +=1

    ecnt[i] = res

res = 0

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

    if s[i+1] == 'W':res+=1

    wcnt[i] = res

ans = 0

for i in range(n):

    ans = max(ans,ecnt[i]+wcnt[i])

ans = n-1-ans

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

s = eval(input())

ecnt = [0]*n

wcnt = [0]*n

for i in range(1,n):

    if s[i-1] == 'W':

        wcnt[i] = wcnt[i-1]+1

    else:

        wcnt[i] = wcnt[i-1]

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

    if s[i+1] == 'E':

        ecnt[i] = ecnt[i+1] +1

    else:

        ecnt[i] = ecnt[i+1]

ans = 10**10

for i in range(n):

    res = ecnt[i]+wcnt[i]

    ans = min(ans,res)

print(ans)



    
n = int(eval(input()))
s = eval(input())
ecnt = [0] * n
wcnt = [0] * n
res = 0
for i in range(1, n):
    # ecnt
    if s[i - 1] == "E":
        res += 1
    ecnt[i] = res
res = 0
for i in range(n - 2, -1, -1):
    if s[i + 1] == "W":
        res += 1
    wcnt[i] = res
ans = 0
for i in range(n):
    ans = max(ans, ecnt[i] + wcnt[i])
ans = n - 1 - ans
print(ans)

n = int(eval(input()))
s = eval(input())
ecnt = [0] * n
wcnt = [0] * n
for i in range(1, n):
    if s[i - 1] == "W":
        wcnt[i] = wcnt[i - 1] + 1
    else:
        wcnt[i] = wcnt[i - 1]
for i in range(n - 2, -1, -1):
    if s[i + 1] == "E":
        ecnt[i] = ecnt[i + 1] + 1
    else:
        ecnt[i] = ecnt[i + 1]
ans = 10**10
for i in range(n):
    res = ecnt[i] + wcnt[i]
    ans = min(ans, res)
print(ans)

-res = 0 -    # ecnt -    if s[i - 1] == "E": -        res += 1 -    ecnt[i] = res -res = 0 +    if s[i - 1] == "W": +        wcnt[i] = wcnt[i - 1] + 1 +    else: +        wcnt[i] = wcnt[i - 1] -    if s[i + 1] == "W": -        res += 1 -    wcnt[i] = res -ans = 0 +    if s[i + 1] == "E": +        ecnt[i] = ecnt[i + 1] + 1 +    else: +        ecnt[i] = ecnt[i + 1] +ans = 10**10 -    ans = max(ans, ecnt[i] + wcnt[i]) -ans = n - 1 - ans +    res = ecnt[i] + wcnt[i] +    ans = min(ans, res)