program cogs121;
const
maxn=30000;
var
n,i,j,w,total:longint;
a:array[1..maxn] of longint;
f:array[1..maxn] of boolean;
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; j:=n;
while (i<j)or(i=j) do
begin
if not f[j] then
begin
f[j]:=true;
if (a[j]+a[i])<=w then
begin
inc(total);
dec(j);
f[i]:=true;
inc(i);
end else
begin
inc(total);
dec(j);
end;
end;
end;
writeln(total);
close(input); close(output);
end.