#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;
bool cmp(int a,int b){
return a<b;
}
int main(){
int w,n,ifir,iend,tol=0;
scanf("%d%d",&w,&n);
int value[n];
ifir=0,iend=n-1;
for(int i=0;i<n;i++){
scanf("%d",&value[i]);
}
sort(value,value+n,cmp);
while(ifir<=iend){
//TODO double point
if(value[ifir]+value[iend]<=w&&(ifir!=iend)){
tol++,ifir++,iend--;
}else{
tol++,iend--;
}
}
printf("%d\n",tol);
return 0;
}