program choose(input,output);
var
a:array[1..20]of integer;
n,k,i,s:integer;
sum:longint;
function check(s:integer):boolean;
var i:integer;
begin
check:=true;
for i:=2 to trunc(sqrt(s)) do
if s mod i=0 then check:=false;
end;
procedure search(m,j:integer);
var i:integer;
begin
if m=k+1 then begin
if check(sum) then s:=s+1;
exit;
end;
for i:=j+1 to n do begin
sum:=sum+a[i];
j:=i;
search(m+1,j);
sum:=sum-a[i];
end;
end;
begin
assign(input,'choose.in');
assign(output,'choose.out');
reset(input);rewrite(output);
readln(input,n,k);
for i:=1 to n do read(input,a[i]);
s:=0;
search(1,0);
write(output,s);
close(input);close(output);
end.