program group(input,output);
var
a:array[1..30000] of integer;
w,n,i,j,s:integer;
procedure qsort(l,r:longint);
var
i,j,x,y:longint;
begin
i:=l;
j:=r;
x:=a[(l+r) div 2];
repeat
while a[i]<x do
inc(i);
while x<a[j] do
dec(j);
if i<=j then
begin
y:=a[i];
a[i]:=a[j];
a[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
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;
while i<=j do
begin
if i=j then
begin
inc(s);
break;
end;
if a[i]+a[j]<=w then
begin
inc(i);
dec(j);
inc(s);
end
else
begin
inc(s);
dec(j);
end;
end;
writeln(s);
close(input);
close(output);
end.