program ex;
var
a:array[1..21] of longint;
f1,f2:text;
i,j,n,k,l,s:longint;
function pd(y:longint):boolean;
var i:longint;
begin
pd:=true;
for i:=2 to y div 2 do
if y mod i =0 then pd:=false;
end;
procedure nb(x:integer);
var i:integer;
begin
for i:=x to n do
begin s:=s+a[i];
j:=j+1;
if j=k then begin if pd(s)=true then l:=l+1;end
else nb(i+1);
s:=s-a[i];j:=j-1;
end;
end;
begin
assign(f1,'choose.in');reset(f1);
assign(f2,'choose.out');rewrite(f2);
readln(f1,n,k);
for i:=1 to n do read(f1,a[i]);
s:=0;j:=0;l:=0;
nb(1);
write(f2,l);
close(f1);close(f2);
end.