local t1, t2 = io.read("*n", "*n")
local a1, a2 = io.read("*n", "*n")
local b1, b2 = io.read("*n", "*n")
if a1 < b1 then
  a1, b1 = b1, a1
  a2, b2 = b2, a2
end
local c1, c2 = a1 - b1, a2 - b2
if c1 * t1 + c2 * t2 == 0 then
  print("infinity")
else
  local red = c1 * t1 + c2 * t2
  if 0 < red then
    print(0)
  else
    red = -red
    if (c1 * t1) % red == 0 then
      local z = math.floor((c1 * t1) / red)
      print(z * 2)
    else
      local z = math.ceil((c1 * t1) / red)
      print(z * 2 - 1)
    end
  end
end
