program conprime(input,output);
var
i,j,k,sum,n:longint;
p:array[1..5000]of longint;
dym:array[1..10000]of longint;
function makeprime:longint;
var
i,j,k:longint;
boo:boolean;
begin
p[1]:=2;
k:=1;
for i:=3 to 10000 do
begin
boo:=true;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then
begin
boo:=false;
break;
end;
if boo then
begin
inc(k);
p[k]:=i;
end;
end;
p[k+1]:=maxlongint;
exit(k);
end;
begin
assign(input,'conprime.in');
reset(input);
assign(output,'conprime.out');
rewrite(output);
n:=makeprime;
for i:=1 to n do
for j:=i to n do
begin
sum:=0;
for k:=i to j do
sum:=sum+p[k];
if sum>10000 then
break;
inc(dym[sum]);
end;
read(n);
while n<>0 do
begin
writeln(dym[n]);
read(n);
end;
close(input);
close(output);
end.