#include <iostream>
#include <vector>
#include <string.h>

using namespace std;
int dp[15][1130];
bool isPrime[1130];
vector<int> prime;

void PrimeCalc()
{
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 1130; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < 1130; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	dp[0][0] = 1;
	for(int i = 0; i < prime.size(); ++i)
	{
		for(int j = 14; j > 0; --j)
		{
			for(int k = prime[i]; k <=1120; ++k)
			{
				dp[j][k] += dp[j - 1][k - prime[i]];
			}
		}
	}
	int n, k;
	while(cin >> n >> k, n || k)
	{
		cout << dp[k][n] << endl;
	}
}

int main()
{
	solve();
	return(0);
}