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