#include using namespace std; //----- using ll = long long; //----- #define ALL(x) (x).begin(),(x).end() #define PRINT(n) cout << n << "\n"; #define REP(i,n) for(int i=0;i<(int)n;++i) void no5(); int main(){ cin.tie(0); ios::sync_with_stdio(false); no5(); } void no5() { ll l, n; cin >> l >> n; vector w(n,0); REP(i,n) cin >> w[i]; sort(ALL(w)); int ans = 0; REP(i,n){ l -= w[i]; if (l >= 0){ ans++; } } PRINT(ans) cout << flush; }