#include using namespace std; int main(){ int l,n; cin >> l >> n; vector data(n); for(auto &a:data) cin >> a; sort(data.begin(),data.end()); int size = 0; for(int i = 0; i < n; i++){ size += data[i]; if(size > l){ cout << i << endl; break; } if(size == l){ cout << i + 1 << endl; break; } if(i == n-1){ cout << n << endl; break; } } return 0; }