#include <cstdio>
#include <vector>
using namespace std;

bool isnp[1121];
int dp[15][1121];

int main(){
	for(int i = 2; i < 40; ++i){
		if( !isnp[i] ){
			for(int j = i * i; j <= 1120; j += i){
				isnp[j] = true;
			}
		}
	}

	dp[0][0] = 1;
	for(int i = 2; i < 1120; ++i){
		if( !isnp[i] ){
			for(int k = 14; k > 0; --k){
				for(int j = 1120; j >= i; --j){
					dp[k][j] += dp[k-1][j-i];
				}
			}
		}
	}
	
	int n, k;
	while(scanf("%d%d", &n, &k), n != 0){
		printf("%d\n", dp[k][n]);
	}
}