#include using namespace std; int main(){ int x, n; cin >> x >> n; vector arr(n); for(auto &ele: arr) cin >> ele; sort(arr.begin(), arr.end()); int ans = 0, tot = 0; for(auto ele: arr){ if(tot + ele <= x){ tot += ele; ans++; } } cout << ans << "\n"; return 0; }