program xuanshu;
var
n,k,i,ans:longint;
a,jilu:array[1..20]of longint;
function check:boolean;
var
i,sum:longint;
begin
sum:=0;
for i:=1 to k do
inc(sum,jilu[i]);
for i:=2 to trunc(sqrt(sum)) do
if sum mod i=0 then
exit(false);
exit(true)
end;
procedure sousuo(th,v:longint);
var
i:longint;
begin
if th=k+1 then
begin
if check then
ans:=ans+1;
exit
end;
if n-v>=k-th+1 then
for i:=v+1 to n do
begin
jilu[th]:=a[i];
sousuo(th+1,i)
end
end;
procedure sort(l,r: longint);
var
i,j,x,y: longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if not(i>j) then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
j:=j-1;
end;
until i>j;
if l<j then
sort(l,j);
if i<r then
sort(i,r);
end;
begin
assign (input,'choose.in');
reset (input);
assign (output,'choose.out');
rewrite (output);
readln (n,k);
for i:=1 to n do
read(a[i]);
sort(1,n);
sousuo(1,0);
writeln (ans);
close (input);
close (output)
end.