#include <iostream>
#include <string.h>
using namespace std;
int p[187];
bool h[1121];
int f[15][1121];
void pre()
{
int i, j, len, max, k;
p[0] = 2; len = 0;
for(i = 3; i <= 1120; i += 2)
if(!h[i])
{
p[++len] = i;
for(j = i * i; j <= 1120; j += i) h[j] = 1;
}
//memset(f,0,sizeof(f));
f[0][0] = 1;
for(i = 0; i <= len; i ++)
{
for(k = 1120; k >=p[i] ; k --)
{
for(j = 1; j <= 14; j ++)
f[j][k] += f[j-1][k-p[i]];
}
}
//for(i = 0; i <= 24; i ++) printf("%d ",f[3][i]);
}
int main()
{
pre();
int n, k;
while(scanf("%d %d", &n, &k), n+k)
printf("%d\n",f[k][n]);
}