T1,T2=gets.chomp.split(" ").map(&:to_i)
A1,A2=gets.chomp.split(" ").map(&:to_i)
B1,B2=gets.chomp.split(" ").map(&:to_i)

count = 0
a = T1*A1
b = T1*B1
loop do
    diff1 = a - b
    check1 = a < b 

    a += T2*A2
    b += T2*B2
    diff2 = a - b
    check2 = a < b

    if check1 != check2
        count += 1
    else
        break
    end

    a += T1*A1
    b += T1*B1
    diff3 = a - b
    check3 = a < b

    if check2 != check3
        count += 1
    else
        break
    end

    if diff1 == diff3 && count > 0
        puts 'infinity'
        exit
    end

    a += T2*A2
    b += T2*B2
    diff4 = a - b
    if diff2 * diff4 > 0
        count += diff2 / (diff4-diff2)
    else
        break
    end

    a += T1*A1
    b += T1*B1
    if diff3 * diff5 > 0
        count += diff3 / (diff5-diff3)
    else
        break
    end
    break
end

puts count
