program conprime(input,output);
var
i,j,k,l,n,aa:longint;
a:array[0..2000]of longint;
b:array[0..10001]of longint;
c:boolean;
begin
k:=0;
for i:=2 to 10000 do
begin
c:=true;
for j:=trunc(sqrt(i)) downto 2 do
if (i mod j)=0 then begin c:=false; break; end;
if c then
begin
inc(k);
a[k]:=i;
end;
end;
a[0]:=0;
for i:=2 to k do
a[i]:=a[i]+a[i-1];
for i:=1 to 10001 do
b[i]:=0;
for i:=1 to k do
for j:=i to k do
begin
if a[j]-a[i-1]<10001 then
inc(b[a[j]-a[i-1]]);
end;
assign(input,'conprime.in');
reset(input);
assign(output,'conprime.out');
rewrite(output);
readln(n);
while n<>0 do
begin
writeln(b[n]);
readln(n);
end;
close(input);
close(output);
end.