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