program interval_running
  implicit none
  integer(8) :: t(2), a(2), b(2), p, q, x, y
  read(*,*) t
  read(*,*) a
  read(*,*) b
  p = (a(1)-b(1))*t(1)
  q = (a(2)-b(2))*t(2)
  if (p > 0_8) then
    p = -p
    q = -q
  end if
  if (p+q < 0_8) then
    write(*,'(i0)') 0
    stop
  else if (p+q == 0_8) then
    write(*,'(a)') "infinity"
    stop
  end if
  x = -p/(p+q)
  y = min(mod(-p,p+q),1_8)
  write(*,'(i0)') 2_8*x+y
end program interval_running