program xxxx;
var
a,b:array[1..10000] of integer;
p,w,z,n:integer;
f,f1:text;
procedure sushu(k:integer);
var i,j,y:integer;
x:real;
begin
x:=sqrt(k);
y:=trunc(x);
for i:=3 to k do
for j:=2 to y do
if ((i mod j)=0)and(i<>j) then
a[i]:=1;
end;
procedure work(k:integer);
var i,j,x,y,l:integer;
begin
if w>k then
x:=k
else
x:=w;
for i:=1 to x do
begin
j:=i;
y:=0;
repeat
begin
y:=y+b[j];
inc(j);
end
until y+b[j]>k;
if y=k then
z:=z+1;
end;
end;
begin
assign(f,'conprime.in');
reset(f);
assign(f1,'conprime.out');
rewrite(f1);
w:=0;
for p:=2 to 10000 do
a[p]:=0;
sushu(10000);
for p:=2 to 10000 do
if a[p]=0 then
begin
inc(w);
b[w]:=p;
end;
repeat
begin
z:=0;
read(f,n);
if n<>0 then
begin
work(n);
writeln(f1,z);
end;
end;
until n=0;
close(f);
close(f1);
end.