let n, s = Scanf.scanf " %d %s" @@ fun a b -> a, b
let ans = ref max_int
let ls, rs = Array.make (n + 1) 0, Array.make (n + 1) 0
let _ =
  for i = 0 to n - 1 do ls.(i + 1) <- ls.(i) + if s.[i] = 'W' then 1 else 0 done;
  for i = n - 1 downto 0 do rs.(i) <- rs.(i + 1) + if s.[i] = 'E' then 1 else 0 done;
  for i = 0 to n - 1 do ans := min !ans @@ ls.(i) + rs.(i + 1) done;
  Printf.printf "%d\n" !ans