program choose;
var
f1,f2:text;
a,x:array[0..1000] of longint;
s,c:longint;
i,m,n:integer;
function cl(s:longint):boolean;
var
i:integer;
begin
cl:=true;
for i:=2 to trunc(sqrt(s)) do
if s mod i=0 then cl:=false;
end;
procedure make(k:integer);
var
i:integer;
begin
if k=m+1 then begin
if cl(s) then inc(c);
exit;
end;
for i:=a[k-1]+1 to n do
begin
s:=s+x[i];
a[k]:=i;
make(k+1);
s:=s-x[i];
end;
end;
begin
assign(f1,'choose.in');
assign(f2,'choose.out');
reset(f1);
rewrite(f2);
readln(f1,n,m);
for i:=1 to n do read(f1,x[i]);
a[0]:=0; c:=0;
make(1);
writeln(f2,c);
close(f1);
close(f2);
end.