program bing;
const
max=10000;
var
f1,f2:text;
k:integer;
a:array[1..10000] of integer;
procedure pre;
var
i,j:integer;
f:boolean;
begin
a[1]:=2;
k:=1;
for i:=3 to max do
begin
f:=true;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then
begin
f:=false;
break;
end;
if f then begin
inc(k);
a[k]:=i;
end;
end;
end;
procedure init;
begin
assign(f1,'conprime.in');reset(f1);
assign(f2,'conprime.out');rewrite(F2);
pre;
end;
procedure nb;
var
i,j,n,s,x:integer;
begin
readln(f1,n);
while n<>0 do
begin
s:=0;
for i:=1 to k do
begin
if a[i]>n then break;
j:=i;
x:=0;
repeat
x:=x+a[j];
inc(j);
until x>=n;
if x=n then inc(s);
end;
writeln(F2,s);
readln(f1,n);
end;
end;
begin
init;
nb;
close(f1);close(f2);
end.