program main
  implicit none
  integer :: n, i, nout, mi
  character(300000) :: s

  read(*, *) n
  read(*, *) s

  nout = 0
  do i = 2, n
    if (s(i:i) == "E") then
      nout = nout + 1
    end if
  end do

  mi = nout
  do i = 2, n
    if (s(i:i) == "E") then
      nout = nout - 1
    end if
    if (s(i - 1:i - 1) == "W") then
      nout = nout + 1
    end if
    mi = min(mi, nout)
  end do
  write(*, "(i0)") mi
end program main
