program cogs121;
const
maxn=30000;
var
n,i,j,w,total:longint;
a:array[1..maxn] of longint;
procedure kp(l,r:longint);
var
i,j,x,t:longint;
begin
i:=l; j:=r;
x:=a[(l+r) div 2];
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'); reset(input);
assign(output,'group.out'); rewrite(output);
total:=0;
readln(w);
readln(n);
for i:=1 to n do readln(a[i]);
kp(1,n);
i:=1;
while i<=n do
begin
if i<>n then
begin
if (a[i]+a[i+1])<=w then begin inc(total); inc(i,2); end else
begin
inc(total);
inc(i);
end;
end else begin inc(total); inc(i); end;
end;
writeln(total-1);
close(input); close(output);
end.