t1, t2 = gets.split.map(&:to_i)
a1, a2 = gets.split.map(&:to_i)
b1, b2 = gets.split.map(&:to_i)
da1 = t1 * a1
db1 = t1 * b1
df1 = da1 - db1
da2 = t2 * a2
db2 = t2 * b2
df2 = da2 - db2

if df1 > 0
    df1 *= -1
    df2 *= -1
end

if df1 + df2 == 0
    puts "infinity"
elsif df1 + df2 < 0
    puts 0
else
    s = -1 * df1 / (df1 + df2)
    t = (-1 * df1) % (df1 + df2)
    if t == 0
        ans = s * 2
    else
        ans = s * 2 + 1
    end
end
puts ans