(
    (stdin.ReadLine() |> int),
    (stdin.ReadLine() |> Seq.map string |> Seq.toArray)
)
|> fun (n, s) ->
  [1..(n - 1)]
  |> Seq.fold (fun (prev, prevRet, ret) x ->
    s.[x]
    |> (fun cur ->
      (
          (if prev = "E" then  0 else 1),
          (if cur  = "E" then -1 else 0)
      )
      |> (fun (a, b) -> prevRet + a + b)
      |> (fun newPrevRet ->
          (cur, newPrevRet, min ret newPrevRet)
      )
    )
  ) (
    s.[1..(n - 1)]
    |> Seq.filter (fun x -> x = "E") 
    |> Seq.length
    |> fun x -> (s.[0], x, x)
  )
  |> (fun (_, _, ret) -> ret)
  |> printfn "%d"
