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
pos = df1 + df2

if pos == 0 || df2 == 0
    puts "infinity"
elsif df1 * pos > 0
    puts 0
else
    max = [df1, df2].max
    min = [df1, df2].min
    diff = max + min
    ans = (max / diff) + (min / diff).abs - 1
    if max % diff == 0 || min % diff == 0
        ans += 1
    end
end
puts ans