#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 1130;
const int MAX_K = 17;

bool p[MAX_N];
vector<int> vp;

void make_p(){
  REP(i, MAX_N) p[i] = true;
  p[0] = p[1] = false;
  for(int i = 2; i < MAX_N; ++i){
    if(!p[i]) continue;
    vp.push_back(i);
    for(int j = i + i; j < MAX_N; j += i) p[j] = false;
  }
}

int main() {
  make_p();
  int N, K, dp[MAX_N][MAX_K];
  memset(dp, 0, sizeof(dp));
  REP(i, vp.size()){
    int p = vp[i];
    for(int k = MAX_K - 2; k >= 0; --k){
      REP(n, MAX_N){
        if(p + n >= MAX_N) break;
        dp[n + p][k + 1] += dp[n][k];
      }
    }
    dp[p][1] += 1;
  }
  while(cin >>N >>K && K) cout <<dp[N][K] <<endl;
  return 0;
}