program choose;
type sz=array[1..20]of longint;
var i,n,k:1..20;
x:sz;
ans:longint;
f1:text;
function zhs(n:longint):boolean;
var i:longint;
begin
zhs:=true;
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then
begin
zhs:=false;
break;
end;
end;
procedure cho(jl,k:byte; shuzu:sz; he:longint);
var kb,i:1..20;
sum:longint;
begin
for i:=jl+1 to n do
begin
kb:=k;
sum:=he;
sum:=sum+shuzu[i];
kb:=kb-1;
if kb>0 then cho(i,kb,shuzu,sum) else
begin
if zhs(sum) then ans:=ans+1;
end;
end;
end;
begin
assign(f1,'choose.in');
reset(f1);
readln(f1,n,k);
for i:=1 to n do
read(f1,x[i]);
close(f1);
cho(0,k,x,0);
assign(f1,'choose.out');
rewrite(f1);
writeln(f1,ans);
close(f1);
end.