program choose;
var
i,sum,n,k:integer;
a:array [1..20] of longint;
function judge(n:longint):boolean;
var i:longint;
begin
judge:=true;
for i:=2 to trunc(sqrt(n)) do if n mod i=0 then judge:=false;
end;
procedure go(no,k:integer;s:longint);
var i:integer;
begin
if no<=n+1 then
if (k=0) then begin
if (judge(s)) and (s<>0) then inc(sum)
end
else for i:=1 downto 0 do go(no+1,k-i,s+i*a[no]);
end;
begin
assign (input,'choose.in');
reset (input);
readln (n,k);
for i:=1 to n do read(a[i]);
close (input);
assign (output,'choose.out');
rewrite (output);
sum:=0;
go (1,k,0);
writeln (sum);
close (output);
end.