program cch(input,output);
var
a:array[1..30000] of integer;
i,j,w,n,ans:integer;
procedure qsort(l,r:integer);
var
i,j,x,temp:integer;
begin
i:=l; j:=r;
x:=a[(l+r) div 2];
repeat
while x>a[i] do inc(i);
while x<a[j] do dec(j);
if i<=j then
begin
temp:=a[i]; a[i]:=a[j];
a[j]:=temp;
inc(i); dec(j);
end;
until i>j;
if i<r then qsort(i,r);
if j>l then qsort(l,j);
end;
begin
assign(input,'group.in');
assign(output,'group.out');
reset(input);
rewrite(output);
readln(w);
readln(n);
for i:=1 to n do
readln(a[i]);
qsort(1,n);
i:=1; j:=n;
ans:=0;
while i<j do
begin
if a[i]+a[j]<=w then inc(i);
inc(ans); dec(j);
end;
if i=j then inc(ans);
write(ans);
close(input);
close(output);
end.