program cojs121;
var
t,front,tail,ans,i,w,n:longint;
a:array[1..30010]of longint;
procedure qsort(l,r:longint);
var
i,j,x,t:longint;
begin
randomize;
i:=l; j:=r;
x:=a[random(r-l+1)+l];
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 qsort(i,r);
if l<j then qsort(l,j);
end;
begin
assign(input,'group.in');reset(input);
assign(output,'group.out');rewrite(output);
readln(w);
readln(n);
for i:=1 to n do
readln(a[i]);
qsort(1,n);
front:=1; tail:=n; ans:=0;
while front<=tail do
begin
t:=a[front]+a[tail];
if t<=w then begin inc(front); dec(tail); inc(ans); end
else begin dec(tail); inc(ans); end;
end;
writeln(ans);
close(input);close(output);
end.