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