#include <iostream>
#include <string>
#include <vector>
using namespace std;

long long cache[1024][1024];
vector<int> primes;


long long dp(int num, int prime) {
  if (prime >= primes.size() || primes[prime] > num) return 1;
  if (num == 0) return 1;
  if (cache[num][prime] != -1) return cache[num][prime];

  long long ret = 0;
  int p = primes[prime];
  for(int i = 0; i*p <= num; i++) {
    ret += dp(num - i*p, prime+1);
  }
  //cout << "num = " << num << " prime " << p << " answer " << ret << endl;
  return cache[num][prime] = ret;
}

int main() {
  for(int i = 2; i <= 1005; i++) {
    bool prime = true;
    for(int j = 2; j*j <= i && prime; j++)
      if (i%j == 0) prime = false;
    if (prime) primes.push_back(i);
  }
  memset(cache, -1, sizeof(cache));
  int n;
  while(cin >> n && n) cout << dp(n, 0) << endl;
  return 0;
}

