var
a:array[1..11000] of integer;
b:array[1..100] of integer;
j,n,m,next,sum:longint;
function check:boolean;
var i:integer;
begin
for i:=1 to m do
if a[b[i]]>0 then exit(true);
check:=false;
end;
begin
assign(input,'waterj.in');
assign(output,'waterj.out');
reset(input);
rewrite(output);
readln(n,m);
for j:=1 to n do read(a[j]);
for j:=1 to m do b[j]:=j;
next:=m+1;
repeat
for j:=1 to m do
begin
dec(a[b[j]]);
if a[b[j]]=0 then
begin
b[j]:=next;
inc(next);
end;
end; inc(sum);
until not check;
writeln(sum);
close(input);
close(output);
end.