#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <stdio.h>
#include <queue>
//#include "windows.h"

#define pb push_back
#define ppb pop_back
#define mp make_pair
#define nd second
#define st first
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define irt pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

using namespace std; 

int n; 
int ans; 
int a[10005]; 

vector <int> v; 

void cp()
{
	v.pb(0); 
	FOR(i, 2, 10000)
		if (!a[i])
		{
			FOR(j, 2, 10000 / i + 1)
				a[i * j] = true; 
			v.pb(i); 
		}
	
	int lst = 0; 
	FOR(i, 1, v.size())
	{
		v[i] += lst; 
		lst = v[i]; 
	}
}

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	cp(); 
	
	while (cin >> n && n)
	{
		REP(i, v.size())
			FOR(j, i + 1, v.size())
				if (v[j] - v[i] == n) ans++; 
		cout << ans << endl; 
		
		ans = 0; 
	}
	
	return 0;
}

