program conprime;
var
p:array [0..1500] of integer;
sum,n,i,j,k:integer;
procedure prime;
var flag:array [1..10000] of boolean;
begin
fillchar (flag,sizeof(flag),0);
flag[1]:=true;i:=2;
while i<=10000 do begin
j:=2;k:=i*j;
while k<=10000 do begin
flag[k]:=true;
inc(j);
k:=i*j;
end;
inc(i);
while (i<=10000) and (flag[i]=true) do inc(i);
end;
for i:=1 to 10000 do if flag[i]=false then begin
inc(p[0]);
p[p[0]]:=i;
end;
end;
begin
fillchar (p,sizeof(p),0);
prime;
assign (input,'conprime.in');
reset (input);
assign (output,'conprime.out');
rewrite (output);
readln (n);
repeat
sum:=0;i:=1;
while p[i]<=n do begin
k:=0;j:=i;
while k<n do begin
inc(k,p[j]);
inc(j);
end;
if k=n then inc(sum);
inc(i);
end;
writeln (sum);
readln (n);
until n=0;
close (input);
close (output);
end.