l = 7368791
loop do
    m, n = gets.split.map(&:to_i)
    break if m == 0
    a = Array.new(l + 1, true)
    (m..l).each do |x|
        if a[x]
            if n == 0
                puts x
                break
            end
            (2..l).each do |y|
                k = x * y
                break if k > l
                a[k] = false
            end
            n -= 1
        else
            next
        end
    end
end
