T1, T2 = gets.split.map &:to_i
A1, A2 = gets.split.map &:to_i
B1, B2 = gets.split.map &:to_i

if (a = T1 * A1 + T2 * A2) == (b = T1 * B1 + T2 * B2)
    puts :infinity
    exit
end

ans = 0
i = 0
while true
    continue = false
    if (i != 0 && (i * a <=> i * b) != (i * a + T1 * A1 <=> i * b + T1 * B1))
        ans += 1
        continue = true
    end
    if (i * a + T1 * A1 <=> i * b + T1 * B1) != ((i + 1) * a <=> (i + 1) * b)
        ans += 1
        continue = true
    end
    if continue
        i += 1
    else
        break
    end
end
p ans