var
n:longint;
a:array[1..30000] of longint;
procedureqsort(l,r:longint);var
i,j,key,temp:longint;
beginif l>=r thenexit;
i:=l;j:=r;
key:=a[l+random(r-l+1)];
repeatwhile (a[i]<key) do inc(i);
while (a[j]>key) do dec(j);
if i<=j thenbegin
temp:=a[i];a[i]:=a[j];a[j]:=temp;
inc(i);dec(j);
end;
until i>j;
qsort(l,j);
qsort(i,r);
end;
var
i,j,m,p:longint;
begin
readln(m);
readln(n);
for i:=1to n do readln(a[i]);
randomize;
qsort(1,n);
j:=n;i:=1;
while i<=j doif a[i]+a[j]<=m thenbegin inc(i);inc(p);dec(j);endelseif a[j]<=m thenbegin dec(j);inc(p);endelse dec(j);
writeln(p);
end.