N = int(eval(input()))

S = eval(input())

L = [S[1:].count('E'),S[:N].count('W')]

k = 0

w = 0

e = S[1:].count('E')

while (k <= N-2):

  if (S[k] == 'W' and S[k+1] == 'W'):

    w += 1

  elif (S[k] == 'W' and S[k+1] == 'E'):

    w += 1

    e -= 1

  elif (S[k] == 'E' and S[k+1] == 'W'):

    w += 0

  else:

    e -= 1

  L.append(e+w)

  k += 1

  

print((min(L)))
N = int(eval(input()))

S = eval(input())

E = []

W = []

k = 0

for i in range(N):

  if S[i] == 'E':

    k += 1

  E.append(k)

l = 0

for i in range(N):

  if S[N-i-1] == 'W':

    l += 1

  W.append(l)

W.reverse()

ME = E[N-1]

MW = W[0]

ans = float('inf')

for i in range(N):

  if ans >= ME-E[i]+MW-W[i]:

    ans = ME-E[i]+MW-W[i]

print(ans)
N = int(eval(input()))
S = eval(input())
L = [S[1:].count("E"), S[:N].count("W")]
k = 0
w = 0
e = S[1:].count("E")
while k <= N - 2:
    if S[k] == "W" and S[k + 1] == "W":
        w += 1
    elif S[k] == "W" and S[k + 1] == "E":
        w += 1
        e -= 1
    elif S[k] == "E" and S[k + 1] == "W":
        w += 0
    else:
        e -= 1
    L.append(e + w)
    k += 1
print((min(L)))

N = int(eval(input()))
S = eval(input())
E = []
W = []
k = 0
for i in range(N):
    if S[i] == "E":
        k += 1
    E.append(k)
l = 0
for i in range(N):
    if S[N - i - 1] == "W":
        l += 1
    W.append(l)
W.reverse()
ME = E[N - 1]
MW = W[0]
ans = float("inf")
for i in range(N):
    if ans >= ME - E[i] + MW - W[i]:
        ans = ME - E[i] + MW - W[i]
print(ans)

-L = [S[1:].count("E"), S[:N].count("W")] +E = [] +W = [] -w = 0 -e = S[1:].count("E") -while k <= N - 2: -    if S[k] == "W" and S[k + 1] == "W": -        w += 1 -    elif S[k] == "W" and S[k + 1] == "E": -        w += 1 -        e -= 1 -    elif S[k] == "E" and S[k + 1] == "W": -        w += 0 -    else: -        e -= 1 -    L.append(e + w) -    k += 1 -print((min(L))) +for i in range(N): +    if S[i] == "E": +        k += 1 +    E.append(k) +l = 0 +for i in range(N): +    if S[N - i - 1] == "W": +        l += 1 +    W.append(l) +W.reverse() +ME = E[N - 1] +MW = W[0] +ans = float("inf") +for i in range(N): +    if ans >= ME - E[i] + MW - W[i]: +        ans = ME - E[i] + MW - W[i] +print(ans)