#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;
int su[10001];
int h;
int S[10001];
int f[10001];
int main()
{
freopen("conprime.in","r",stdin);
freopen("conprime.out","w",stdout);
for (int i=2;i<=10000;i++)
{
int t=(int)sqrtf((float)i);
int j;
for (j=2;j<=t;j++)
if (i%j==0) break;
if (j>t)
{
su[++h]=i;
S[h]=S[h-1]+su[h];
}
}
for (int i=0;i<=h;i++)
for (int j=i+1;j<=h;j++)
{
if (S[j]-S[i]<=10000) f[S[j]-S[i]]+=1;
}
int t;
do
{
scanf("%d",&t);
if (!t) break;
printf("%d\n",f[t]);
}while (true);
return 0;
}