let split_string ?(pattern="") = Str.split @@ Str.regexp pattern
let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let s = read_line () |> split_string |> Array.of_list

let west, east = 
  Array.init n (fun i -> if s.(i) = "W" then 1 else 0), 
  Array.init n (fun i -> if s.(i) = "E" then 1 else 0)

let () =  
  let ans = ref max_int in
  for i = 1 to n - 1 do west.(i) <- west.(i) + west.(i - 1) done;
  for i = n - 2 downto 0 do east.(i) <- east.(i) + east.(i + 1) done;
  ans := min east.(1) west.(n - 2);
  for i = 1 to n - 2 do
    ans := min !ans (west.(i - 1) + east.(i + 1))
  done;
  Printf.printf "%d\n" !ans