#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; int count = 1; for(int i = 0; i < n; i++){ size += data[i]; if(size > l){ count--; break; }else if(size == l){ break; } count++; } cout << count << endl; return 0; }