let result = ref 1000000
let () =
  let n = Scanf.scanf "%d " (fun x -> x) in
  let s = Array.init n (fun _ -> Scanf.scanf "%c"
                                  (fun x -> x)) in
  for i = 0 to (n-1) do
    let left = Array.sub s 0 i in
    let right = Array.sub s (i+1) (n-i-1)  in
    let left' = Array.to_list left in
    let right' = Array.to_list right in
    let res_l =
      List.fold_left (fun sum x ->
          match x with
          | 'W' -> sum + 1
          | 'E' -> sum) 0 left' in
    let res_r =
      List.fold_left (fun sum x ->
          match x with
          | 'E' -> sum + 1
          | 'W' -> sum) 0 right' in
    let res = res_l + res_r in
    if res < !result then
      result := res
    else
      ()
  done;
  Printf.printf "%d\n" !result

