#include #include using namespace std; int main () { int L,N,a[11111],i; cin >> L >> N; for(i = 0;i < N;i++) cin >> a[i]; sort(a,a + N); i = 0; int j = 0; int sum = 0; while(a[i] < L) { L -= a[i]; i++; j++; } cout << j << endl; return 0; }