#include #include using namespace std; using ll=long long; using vll=vector; using pll=pair; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll L,N; cin>>L>>N; vll w(N+1); for(int i=1;i<=N;++i)cin>>w[i]; sort(w.begin()+1,w.end()); ll cur=0,ans=0; for(int i=1;i<=N;++i){ if(cur+w[i]>L)break; else cur+=w[i],ans++; } cout<