program conprime;
var
p:array [1..1300] of integer;
n,total,ans,i,j,s:integer;
procedure get;
var
flag:array [1..10000] of boolean;
i,j,t:integer;
begin
fillchar (flag,sizeof(flag),0);
for i:=2 to 100 do begin
t:=i*i;
repeat
flag[t]:=true;
t:=t+i;
until t>10000;
end;
total:=1;i:=3;
p[total]:=2;
repeat
if not(flag[i]) then begin
inc(total);
p[total]:=i;
end;
inc(i,2);
until i>10000;
end;
begin
assign (input,'conprime.in');
reset (input);
assign (output,'conprime.out');
rewrite (output);
readln (n);
get;
while n<>0 do begin
ans:=0;s:=0;
for i:=1 to total do begin
s:=p[i];
if s>n then break;
for j:=i+1 to total do begin
if s=n then begin
inc(ans);
break;
end
else if s>n then break;
s:=s+p[j];
end;
end;
writeln (ans);
readln (n);
end;
close (input);
close (output);
end.