program lianxusushuhe;
var
i,j,t,n:longint;
a,s:array[0..10000]of longint;
f:array[0..1500]of longint;
biaozhi:boolean;
begin
assign (input,'conprime.in');
reset (input);
assign (output,'conprime.out');
rewrite (output);
for i:=2 to 10000 do
begin
biaozhi:=true;
for j:=2 to trunc(sqrt(i)) do
if i mod j =0 then
begin
biaozhi:=false;
break
end;
if biaozhi then
begin
t:=t+1;
a[t]:=i
end
end;
f[1]:=a[1];
for i:=2 to t do
f[i]:=f[i-1]+a[i];
for i:=1 to t do
for j:=i to t do
if f[j]-f[i-1]<=10000 then
s[f[j]-f[i-1]]:=s[f[j]-f[i-1]]+1;
repeat
readln (n);
if n<>0 then
writeln (s[n])
until n=0;
close (input);
close (output)
end.