N = int(eval(input()))

S = eval(input())



min_count = N



left = {'W':0, 'E':0}

w = S.count('W')

right = {'W':w, 'E':N-w}



for i in range(N):

    base = S[i]

    right[base] -= 1

    min_count = min(left['W']+right['E'], min_count)

    left[base] += 1

print(min_count)
from collections import deque



N = int(eval(input()))

S = eval(input())



count = deque()



left = {'W':0, 'E':0}

w = S.count('W')

right = {'W':w, 'E':N-w}



for i in range(N):

    base = S[i]

    right[base] -= 1

    count.append(left['W']+right['E'])

    left[base] += 1

print((min(count)))
N = int(eval(input()))
S = eval(input())
min_count = N
left = {"W": 0, "E": 0}
w = S.count("W")
right = {"W": w, "E": N - w}
for i in range(N):
    base = S[i]
    right[base] -= 1
    min_count = min(left["W"] + right["E"], min_count)
    left[base] += 1
print(min_count)

from collections import deque

N = int(eval(input()))
S = eval(input())
count = deque()
left = {"W": 0, "E": 0}
w = S.count("W")
right = {"W": w, "E": N - w}
for i in range(N):
    base = S[i]
    right[base] -= 1
    count.append(left["W"] + right["E"])
    left[base] += 1
print((min(count)))

+from collections import deque + -min_count = N +count = deque() -    min_count = min(left["W"] + right["E"], min_count) +    count.append(left["W"] + right["E"]) -print(min_count) +print((min(count)))