program main
  implicit none
  integer i, A(5), ans
  !read(*, *)
  read(*, *) (A(i), i = 1,5)
  ans = 0
  do i = 1,5
    if (A(i) == 0) then
      ans = i
    endif
  end do
  write(*, *) ans
end program main
