def ina
  gets.split(' ').map(&:to_i)
end
t1, t2 = ina
a1, a2 = ina
b1, b2 = ina
k1 = t1 * (a1 - b1)
k2 = t2 * (a2 - b2)
stride = k1 + k2
if stride.zero?
  puts 'infinity'
elsif (k1 * stride).positive?
  puts 0
else
  ceil = (k1.abs + (stride.abs - 1)) / stride.abs
  bent = k1 % stride == 0
  res = (ceil - 1) + ceil + (bent ? 1 : 0)
  p res
end