import collections

n = int(eval(input()))

s = eval(input())

dic = dict(collections.Counter(s))

#W,Eどちらかしか無い場合

if len(dic)==1:

  print((0))

  exit()

left_w = 0

right_e = dic["E"]

cnt = [[] for _ in range(n)]

#(左にあるWの数+右にあるEの数)の最小値が答え





ans = n

for i in range(n):

  if s[i] == "W":

    cnt[i] = [left_w,right_e]

    ans = min(ans,left_w+right_e)

    left_w += 1

  elif s[i] == "E":

    cnt[i] = [left_w,right_e]

    ans = min(ans,left_w+right_e)

    right_e -= 1



#(右にあるWの数+左にあるEの数)の最小値が答えの場合もあるか

left_e = 0

right_w = dic["W"]



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

  if s[i] == "E":

    ans = min(ans,left_e+right_w)

    left_e += 1

  elif s[i] == "W":

    ans = min(ans,left_e + right_w)

    right_w -= 1



print(ans)



import collections

n = int(eval(input()))

s = eval(input())

dic = dict(collections.Counter(s))

#W,Eどちらかしか無い場合

if len(dic)==1:

  print((0))

  exit()

left_w = 0

right_e = dic["E"]



#(左にあるWの数+右にあるEの数)の最小値が答え

ans = n

for i in range(n):

  if s[i] == "W":

    ans = min(ans,left_w+right_e)

    left_w += 1

  elif s[i] == "E":

    ans = min(ans,left_w+right_e)

    right_e -= 1



#(右にあるWの数+左にあるEの数)の最小値が答えの場合もあるか

left_e = 0

right_w = dic["W"]



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

  if s[i] == "E":

    ans = min(ans,left_e+right_w)

    left_e += 1

  elif s[i] == "W":

    ans = min(ans,left_e + right_w)

    right_w -= 1



print(ans)



import collections

n = int(eval(input()))
s = eval(input())
dic = dict(collections.Counter(s))
# W,Eどちらかしか無い場合
if len(dic) == 1:
    print((0))
    exit()
left_w = 0
right_e = dic["E"]
cnt = [[] for _ in range(n)]
# (左にあるWの数+右にあるEの数)の最小値が答え
ans = n
for i in range(n):
    if s[i] == "W":
        cnt[i] = [left_w, right_e]
        ans = min(ans, left_w + right_e)
        left_w += 1
    elif s[i] == "E":
        cnt[i] = [left_w, right_e]
        ans = min(ans, left_w + right_e)
        right_e -= 1
# (右にあるWの数+左にあるEの数)の最小値が答えの場合もあるか
left_e = 0
right_w = dic["W"]
for i in range(n - 1, -1, -1):
    if s[i] == "E":
        ans = min(ans, left_e + right_w)
        left_e += 1
    elif s[i] == "W":
        ans = min(ans, left_e + right_w)
        right_w -= 1
print(ans)

import collections

n = int(eval(input()))
s = eval(input())
dic = dict(collections.Counter(s))
# W,Eどちらかしか無い場合
if len(dic) == 1:
    print((0))
    exit()
left_w = 0
right_e = dic["E"]
# (左にあるWの数+右にあるEの数)の最小値が答え
ans = n
for i in range(n):
    if s[i] == "W":
        ans = min(ans, left_w + right_e)
        left_w += 1
    elif s[i] == "E":
        ans = min(ans, left_w + right_e)
        right_e -= 1
# (右にあるWの数+左にあるEの数)の最小値が答えの場合もあるか
left_e = 0
right_w = dic["W"]
for i in range(n - 1, -1, -1):
    if s[i] == "E":
        ans = min(ans, left_e + right_w)
        left_e += 1
    elif s[i] == "W":
        ans = min(ans, left_e + right_w)
        right_w -= 1
print(ans)

-cnt = [[] for _ in range(n)] -        cnt[i] = [left_w, right_e] -        cnt[i] = [left_w, right_e]