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

x = (b[0] - a[0]) * t[0]
y = (b[1] - a[1]) * t[1]

if x + y == 0
    puts x == y ? 0 : "infinity"
elsif x == 0 || y== 0 || (x > 0 && x + y > 0) || (x < 0 && x + y < 0)
    puts 0
elsif x + y > 0
    s, t = x.abs.divmod(x + y)
    puts t != 0 ? s * 2 + 1 : s * 2
else
    s, t = x.divmod((x + y).abs)
    puts t != 0 ? s * 2 + 1 : s * 2
end