program ioi_to_oio
  implicit none
  integer :: n, a(500000), m, i
  character(500000) :: s
  a = 0
  m = 0
  read(*,*) n
  read(*,*) s
  do i = 1, n
    if (s(i:i).eq."1") a(i) = 1
  end do
  i = 1
  do while (i.le.n)
    if (a(i).eq.1) then
      if (i.ge.3.and.a(i-2)-a(i-1).eq.1) then
        a(i-2) = 0
        a(i-1) = 1
        a(i) = 0
        i = i-2
        m = m+1
        cycle
      end if
    end if
    i = i+1
  end do
  write(*,'(i0)') m
  stop
end program ioi_to_oio