require 'prime'

loop {
    n, p = gets.split.map &:to_i
    break if n < 0
    primes = []
    Prime.each{|x|
        primes << x if x > n
        break if primes.size > p
    }
    puts primes.product(primes).select{|x, y| x <= y}.map{|x, y| x+y}.sort[p-1]
}