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 sys import stdout
  from bisect import bisect_left as binl
  from copy import copy, deepcopy
  from collections import defaultdict
  
  
  mod = 1
  
  
  def intin():
      input_tuple = input().split()
      if len(input_tuple) <= 1:
          return int(input_tuple[0])
      return tuple(map(int, input_tuple))
  
  
  def intina():
      return [int(i) for i in input().split()]
  
  
  def intinl(count):
      return [intin() for _ in range(count)]
  
  
  def modadd(x, y):
      global mod
      return (x + y) % mod
  
  
  def modmlt(x, y):
      global mod
      return (x * y) % mod
  
  
  def lcm(x, y):
      while y != 0:
          z = x % y
          x = y
          y = z
      return x
  
  
  def combination(x, y):
      assert x >= y
  
      if y > x // 2:
          y = x - y
  
      ret = 1
  
      for i in range(0, y):
          j = x - i
          i = i + 1
  
          ret = ret * j
          ret = ret // i
  
      return ret
  
  
  def get_divisors(x):
      retlist = []
      for i in range(1, int(x**0.5) + 3):
          if x % i == 0:
              retlist.append(i)
              retlist.append(x // i)
      return retlist
  
  
  def get_factors(x):
      retlist = []
      for i in range(2, int(x**0.5) + 3):
          while x % i == 0:
              retlist.append(i)
              x = x // i
      retlist.append(x)
      return retlist
  
  
  def make_linklist(xylist):
      linklist = {}
      for a, b in xylist:
          linklist.setdefault(a, [])
          linklist.setdefault(b, [])
          linklist[a].append(b)
          linklist[b].append(a)
      return linklist
  
  
  def calc_longest_distance(linklist, v=1):
      distance_list = {}
      distance_count = 0
      distance = 0
      vlist_previous = []
      vlist = [v]
      nodecount = len(linklist)
  
      while distance_count < nodecount:
          vlist_next = []
          for v in vlist:
              distance_list[v] = distance
              distance_count += 1
              vlist_next.extend(linklist[v])
          distance += 1
          vlist_to_del = vlist_previous
          vlist_previous = vlist
          vlist = list(set(vlist_next) - set(vlist_to_del))
  
      max_distance = -1
      max_v = None
      for v, distance in distance_list.items():
          if distance > max_distance:
              max_distance = distance
              max_v = v
  
      return (max_distance, max_v)
  
  
  def calc_tree_diameter(linklist, v=1):
      _, u = calc_longest_distance(linklist, v)
      distance, _ = calc_longest_distance(linklist, u)
      return distance
  
  
  ###############################################################################
  
  
  def main():
      n = intin()
      s = input()
  
      now = 0
      for c in s[1:]:
          if c == "E":
              now += 1
  
      ans = now
  
      for i in range(n - 1):
          if s[i] == "W":
              now += 1
          if s[i + 1] == "E":
              now -= 1
          ans = min(now, ans)
  
      print(ans)
  
  
  if __name__ == "__main__":
      main()
  
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"}]