var n,i,w,j,ans:longint;
a:array[0..30001]of longint;
procedure kp(l,r:longint);
var i,j,x,t:longint;
begin
i:=l;j:=r;x:=a[(i+j)shr 1];
repeat
while a[i]<x do inc(i);
while a[j]>x do dec(j);
if i<=j then begin
t:=a[i];a[i]:=a[j];a[j]:=t;
inc(i);dec(j);
end;
until i>j;
if i<r then kp(i,r);
if j>l then kp(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
read(a[i]);
kp(1,n);
i:=1;j:=n;ans:=0;
repeat
if a[i]+a[j]<=w then begin
inc(i);inc(ans);dec(j);
end
else if a[j]<=w then begin
inc(ans);dec(j);
end;
until i>j;
write(ans);
close(input);
close(output);
end.