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: # coding:utf-8
  
  import sys
  import math
  import time
  
  # import numpy as np
  import collections
  from collections import deque
  import queue
  import copy
  
  
  # 最大公約数
  def gcd(m, n):
      x = max(m, n)
      y = min(m, n)
      if x % y == 0:
          return y
      else:
          while x % y != 0:
              z = x % y
              x = y
              y = z
          else:
              return z
  
  
  # 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
  def bfs(SS, x, y, H, W):  # 入力(座標系(迷路), x, y, xの端, yの端)
      x_next = [0, 0, -1, 1]
      y_next = [1, -1, 0, 0]
      tempx = x
      tempy = y
      mlength = 0
      q = deque()
      xytuple = (x, y, 0)
      q.append(xytuple)
  
      while q:
          xytuple = q.popleft()
          SS[xytuple[0]][xytuple[1]] = "x"  # 探索した場所は探索できないようにする
          for i in range(4):  # このforで上下左右を調べてる
              tempx = xytuple[0] + x_next[i]
              tempy = xytuple[1] + y_next[i]
              # print(tempx, tempy, xytuple[2])
              # print(S)
              if (
                  0 <= tempx
                  and tempx < H
                  and 0 <= tempy
                  and tempy < W
                  and SS[tempx][tempy] == "."
              ):
                  temptuple = (tempx, tempy, xytuple[2] + 1)
                  SS[temptuple[0]][
                      temptuple[1]
                  ] = "x"  # 探索した場所は探索できないようにする
                  mlength = max(mlength, xytuple[2] + 1)
                  q.append(temptuple)
              # print(q)
      return mlength
  
  
  # 素因数分解
  def prime_factorize(n):
      a = []
      while n % 2 == 0:
          a.append(2)
          n //= 2
      f = 3
      while f * f <= n:
          if n % f == 0:
              a.append(f)
              n //= f
          else:
              f += 2
      if n != 1:
          a.append(n)
      return a
  
  
  # 重複を検出
  def has_duplicates(seq):
      return len(seq) != len(set(seq))
  
  
  # X = str(input()).split()
  # a = [int(x) for x in input().split()]
  
  
  N = int(input())
  S = str(input())
  
  c = S.count("E")
  
  if S[0] == "E":
      c -= 1
  
  ans = 0
  
  temp = c
  
  for i in range(1, N):
      if S[i - 1] == "E":
          if S[i] == "E":
              c -= 1
              if c < temp:
                  ans = i
                  temp = c
      else:
          if S[i] == "W":
              c += 1
  
  
  print(temp)
  
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"}]