#define _GLIBCXX_DEBUG #define ll long long #include using namespace std; using Graph = vector>; void print(auto a){ cout << a; } void printL(auto a){ cout << a << endl; } void L(){ cout << endl; } void jud(int i, int l, vector A){ if(l < 0){ cout << i-1 << endl; return; } if(i == (int)A.size()){ cout << i << endl; return; } jud(i+1, l-A[i], A); } int main(){ int L, N; cin >> L >> N; vector A(N); for(int i = 0; i < N; i++){ cin >> A[i]; } sort(A.begin(), A.end()); jud(0, L, A); }