type aaa=array[1..20] of boolean;
var
i,j,m,n,k,ans:longint;
o0:aaa;
h:array[1..500] of longint;
procedure dfs(v,s:longint;o:aaa);
var i:longint; o1:aaa;
begin
if s=k then begin inc(ans); exit;end;
if v>n then exit;
fillchar(o1,sizeof(o1),0);
for i:=1 to h[v] do o1[i]:=o[i];
dfs(v+1,s,o1);
for i:=1 to h[v] do
begin
if not o1[i] then
begin
o1[i]:=true;
dfs(v+1,s+1,o1);
o1[i]:=false;
end;
end;
end;
begin
assign(input,'boarda.in');reset(input);
assign(output,'boarda.txt');rewrite(output);
readln(n,k);
for i:=1 to n do read(h[i]);
readln;
dfs(1,0,o0);
writeln(ans);
close(input);close(output);
end.