#include<iostream> #include<algorithm> #include<cmath> using namespace std; int cmp(int a,int b){ return abs(a)<abs(b); } int main(){ int i,t,n,data[50005]; scanf("%d%d",&t,&n); for(i=0;i<n;i++){ scanf("%d",&data[i]); } sort(data,data+n,cmp); int sum = 0,cur = 0; i = 0; while(i<n&&sum<=t){ sum += abs(data[i]-cur); cur = data[i]; i++; } if(sum>t) printf("%d\n",i-1); else printf("%d\n",i); return 0; }