output_description: Print the minimum number of people who have to change their directions.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      S
attempt: from statistics import mean, median, variance, stdev
  import numpy as np
  import sys
  import math
  import fractions
  import itertools
  import copy
  import collections
  from operator import itemgetter
  
  
  # 以下てんぷら
  def j(q):
      if q == 1:
          print("You can win")
      else:
          print("You will lose")
      exit(0)
  
  
  def ct(x, y):
      if x > y:
          print("+")
      elif x < y:
          print("-")
      else:
          print("?")
  
  
  def ip():
      return int(input())
  
  
  def printrow(a):
      for i in range(len(a)):
          print(a[i])
  
  
  def combinations(n, r):
      if n < r:
          return 0
      return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
  
  
  def permutations(n, r):
      if n < r:
          return 0
      return math.factorial(n) // math.factorial(n - r)
  
  
  n = ip()  # 入力整数1つ
  # a,b,c= (int(i) for i in input().split())       #入力整数横2つ以上
  # a = [int(i) for i in input().split()]        #入力整数配列
  a = input()  # 入力文字列
  # a = input().split()                          #入力文字配列
  # k = ip()                      #入力セット(整数改行あり)(1/2)
  # a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
  # jの変数はしようできないので注意
  # 全足しにsum変数使用はsum関数使用できないので注意
  # こっから本文
  righte = 0
  rightw = 0
  leftw = 0
  lefte = 0
  for i in range(n):
      if a[i] == "E":
          righte += 1
      else:
          rightw += 1
  s = n
  for i in range(n):
      if a[i] == "E":
          righte -= 1
      else:
          rightw -= 1
      s = min(s, leftw + righte)
      if a[i] == "E":
          lefte += 1
      else:
          leftw += 1
  print(s)
  
problem_description: Statement
  
  There are N people standing in a row from west to east. Each person is facing
  east or west. The directions of the people is given as a string S of length N.
  The i-th person from the west is facing east if S_i = `E`, and west if S_i =
  `W`.
  
  You will appoint one of the N people as the leader, then command the rest of
  them to face in the direction of the leader. Here, we do not care which
  direction the leader is facing.
  
  The people in the row hate to change their directions, so you would like to
  select the leader so that the number of people who have to change their
  directions is minimized. Find the minimum number of people who have to change
  their directions.
samples: [{"input": "5\n    WEEWW", "output": "1\n    \n\nAssume that we appoint the third person from the west as the leader. Then, the\nfirst person from the west needs to face east and has to turn around. The\nother people do not need to change their directions, so the number of people\nwho have to change their directions is 1 in this case. It is not possible to\nhave 0 people who have to change their directions, so the answer is 1.\n\n* * *"}, {"input": "12\n    WEWEWEEEWWWE", "output": "4\n    \n\n* * *"}, {"input": "8\n    WWWWWEEE", "output": "3"}]