program bing;
var
f1,f2:text;
a:array[1..30000] of integer;
i,j,s,w,n:integer;
procedure init;
begin
assign(f1,'group.in');reset(f1);
assign(f2,'group.out');rewrite(f2);
readln(F1,w);
readln(f1,n);
for i:=1 to n do read(f1,a[i]);
end;
procedure kuaipai(x,y:integer);
var
i,j,t,tt:integer;
begin
i:=x;j:=y;
t:=a[(i+j)div 2];
repeat
while a[i]<t do inc(i);
while a[j]>t do dec(j);
if i<=j then
begin
tt:=a[i];
a[i]:=a[j];
a[j]:=tt;
inc(i);
dec(j);
end;
until i>j;
if i<y then kuaipai(i,y);
if j>x then kuaipai(x,j);
end;
begin
init;
kuaipai(1,n);
i:=1;j:=n;s:=0;
repeat
if (a[j]+a[i]>w) then begin dec(j);inc(s);end
else if a[j]+a[i]<=w then begin dec(j);inc(i);inc(s);end;
until i>j;
write(f2,s);
close(f1);close(f2);
end.