t = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)


if t[0]*a[0]+t[1]*a[1] == t[0]*b[0]+t[1]*b[1]
  puts "infinity"
else
  ans = 0
  x,y = 0,0
  idx = 0
  10000.times{|i|
    2.times{|j|
      x += t[j]*a[j]
      y += t[j]*b[j]
      ans += 1 if idx != (x<=>y)
      idx = (x<=>y)
    }
  }
  p ans-1
end