program cch(input,output);
var
tot,i,j,ans,tmp,x:longint;
a:array[1..10000] of integer;
flag:boolean;
begin
assign(input,'conprime.in');
assign(output,'conprime.out');
reset(input);
rewrite(output);
tot:=0;
for i:=2 to 10000 do
begin
flag:=true;
for j:=2 to trunc(sqrt(i)) do
if i mod j=0 then
begin
flag:=false;
break;
end;
if flag then
begin
inc(tot); a[tot]:=i;
end;
end;
readln(x);
while x<>0 do
begin
ans:=0;
for i:=1 to tot do
begin
tmp:=a[i];
if tmp>x then break;
j:=i;
while tmp<x do
begin
inc(j);
inc(tmp,a[j]);
end;
if tmp=x then inc(ans);
end;
writeln(ans);
readln(x);
end;
close(input);
close(output);
end.