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

int main(){
    vector<int> p;
    bool np[1120] = {};
    for(int i = 2; i < 1120; i++){
        if(np[i])   continue;
        p.push_back(i);
        for(int j = i+i; j < 1120; j+=i) np[j] = true;
    }
    vector<vector<int>> dp(15, vector<int>(1121, 0));
    dp[0][0] = 1;
    for(int prime : p){
        for(int i = 14; i >= 1; i--){
            for(int j = prime; j <= 1120; j++){
                dp[i][j] += dp[i-1][j-prime];
            }
        }
    }
    int n, k;
    while(cin >> n >> k, n+k)   cout << dp[k][n] << endl;
    return 0;
}
