#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

const int N = 10000;

vector<int> prime;
bool is_prime[N+1];
int data[1230];

void sieve(){
  fill(is_prime, is_prime+N+1, true);
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i<=N;i++){
    if(is_prime[i]){
      prime.push_back(i);
      for(int j=2*i;j<=N;j+=i) is_prime[j] = false;
    }
  }
}

void init(){
  fill(data, data+1230, 0);
  for(int i=0;i<prime.size();i++){
    data[i+1] = data[i] + prime[i];
  }
}

int main(){
  sieve();
  init();
  int n;
  while(cin >> n && n){
    int l = 0, r = 1;
    int ans = 0;
    while(l < prime.size() && r <= prime.size()){
      int tmp = data[r] - data[l];
      if(tmp == n){
        ans++;
        l++;
      }else if(tmp < n){
        r++;
      }else if(tmp > n){
        l++;
      }
    }
    cout << ans << endl;
  }
}