#include<bits/stdc++.h>
#define io ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
typedef pair<int,int> PII;
#define int long long
int w,n;
const int N = 1e5+10;
int a[N];
int ans;
signed main()
{
io;
cin>>w>>n;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+1+n);
int l=1,r=n;
while(l<=r)
{
if(a[l]+a[r] <= w)
{
l++,r--;
ans++;
}
else
{
if(a[r] <= w)
{
ans++;
}
r--;
}
}
cout<<ans<<endl;
return 0;
}