t1, t2 = gets.split.map(&:to_i)
a1, a2 = gets.split.map(&:to_i)
b1, b2 = gets.split.map(&:to_i)
x1 = (a1 - b1) * t1
x2 = (a2 - b2) * t2
if (x1 > 0) ^ (x2 > 0) then
  x1, x2 = -x1, -x2 if x1 < 0
  sub = -(x1 + x2)
  if sub == 0 then
    puts "infinity"
  elsif sub < 0
    puts 0
  else
    ans = (x1 / sub) * 2
    ans += (x1 % sub == 0) ? 0 : 1
    puts ans
  end
else
  puts 0
end