import std.stdio,std.conv, std.algorithm, std.container,std.array,std.range,std.string,std.typecons,std.numeric,std.math;
const dx = [1,0,-1,0], dy = [0,1,0,-1];
const readMixin = q{ auto line = readln().split();foreach(i,ref arg; args){ if (i >= line.length) return;arg = line[i].to!(typeof(arg));}};
void read(T...)  (auto ref T args){ mixin(readMixin);}
void readArray(T)(auto ref T args){ mixin(readMixin);}
void times(int n,void delegate() stmt){foreach(i;iota(n))stmt();}

auto sieve(){
	const primeMax = 100000;
	bool[primeMax] notPrime;
	notPrime[0] = notPrime[1] = true; 
	for(int i = 2; i * i < primeMax; i++){
		if (notPrime[i]) continue;
		for(int j = i; i * j < primeMax; j++){
			notPrime[i * j] = true;
		}
	}
	return notPrime;
}
void main(){
	int[] primes_;
	foreach(int i,np;sieve()){if(!np)primes_ ~= i;}
	auto primes = primes_.assumeSorted;
	int n,p;
	while(read(n,p),n!=-1 && p != -1){
		auto starts = primes.upperBound(n)[0..p].array;
		int[] m ;
		foreach(i,s1;starts){
			foreach(s2;starts[i..$]){
				m ~= s1 + s2;
			}
		}
		m.sort[p-1].writeln;
	}
}