#include <iostream>
using namespace std;
int P[1300],N,S[1300];
int F[10001];
void makeprime()
{
int i,j;
bool T;
for (i=2;i<=10000;i++)
{
T=false;
for (j=1;j<=N && P[j]*P[j]<=i;j++)
{
if (i%P[j]==0)
{
T=true;
break;
}
}
if (!T)
{
P[++N]=i;
S[N]=S[N-1]+P[N];
}
}
}
void solve()
{
int i,j,Item;
for (i=1;i<=N;i++)
{
for (j=i;j<=N;j++)
{
Item=S[j]-S[i-1];
if (Item<=10000)
F[Item]++;
}
}
do
{
scanf("%d",&Item);
if (Item) printf("%d\n",F[Item]);
}
while (Item);
}
int main()
{
freopen("conprime.in","r",stdin);
freopen("conprime.out","w",stdout);
makeprime();
solve();
return 0;
}