#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000001 int main(){ int l,n; cin>>l>>n; vector w(n); rep(i,n)cin>>w[i]; sort(w.begin(),w.end()); int ans = 0; rep(i,n){ if(w[i]<=l){ l -= w[i]; ans++; } } cout<