program tz;
var
w:integer;
f1,f2:text;
n,i,j,t:longint;
a:array [1..30000] of integer;
procedure sort(l,r:integer);
var
i,j,x,y:integer;
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 i<r then sort(i,r);
if l<j then sort(l,j);
end;
begin
assign(f1,'group.in');
assign(f2,'group.out');
reset(f1);rewrite(f2);
t:=0;
readln(f1,w);
readln(f1,n);
for i:=1 to n do readln(f1,a[i]);
sort(1,n);
i:=1;
j:=n;
while i<=j do
if (a[i]+a[j]<=w) then begin
inc(t);
inc(i);
dec(j);
end
else begin
dec(j);
inc(t);
end;
write(t);
close(f1);
close(f2);
end.