(* O(n) *)
let n = read_int ()
let s = read_line ()
let accs = Array.init 2 @@ fun _ -> Array.make (n + 1) 0
let ans = ref max_int
let _ =
  let cs = [|ref 0; ref 0|] in
  for i = 0 to n - 1 do
    incr @@ if s.[i] = 'W' then cs.(0) else cs.(1);
    for j = 0 to 1 do accs.(j).(i + 1) <- !(cs.(j)) done
  done;
  for i = 0 to n - 1 do
    ans := min !ans @@ accs.(0).(i) + accs.(1).(n) - accs.(1).(i + 1)
  done;
  Printf.printf "%d\n" !ans