program choose(input,output);
type shuzu=array[1..20]of longint;
var
j,n,k:byte;
s:shuzu;
x:longint;
i,o:text;
function zs(n:longint):boolean;
var
i:integer;
begin
if n=2 then zs:=true
else
if not(odd(n)) then zs:=false
else
begin
zs:=true;
for i:=3 to trunc(sqrt(n)) do
if n mod i=0 then begin zs:=false; break; end;
end;
end;
procedure xz(l,k:byte; s:shuzu; h:longint);
var
j,i:1..20;
m:longint;
begin
for i:=l+1 to n do
begin
j:=k;
m:=h;
m:=m+s[i];
dec(j);
if j>0 then xz(i,j,s,m)
else if zs(m) then x:=x+1;
end;
end;
begin
assign(i,'choose.in');
reset(i);
readln(i,n,k);
for j:=1 to n do
read(i,s[j]);
close(i);
xz(0,k,s,0);
assign(o,'choose.out');
rewrite(o);
writeln(o,x);
close(o);
end.