(*
 * 西=左 
 * 東=右
 *)

let () = Scanf.scanf "%d\n%s\n" @@ fun n s ->
  let west = Array.make (n + 2) 0
  in
  let east = Array.make (n + 2) 0
  in
  for i = 0 to n - 1 do
    (if s.[i] = 'W' then
      west.(i + 2) <- 1);
    (if s.[i] = 'E' then
      east.(i) <- 1)
  done;
  for i = 1 to n + 1 do
    west.(i) <- west.(i) + west.(i - 1);
  done;
  for i = n downto 0 do
    east.(i) <- east.(i) + east.(i + 1)
  done;
  Array.init n (fun i -> west.(i + 1) + east.(i + 1))
  |> Array.fold_left min max_int
  |> Printf.printf "%d\n"
