#include #include #include #include #include #include #include #include using namespace std; using ll = long long; const ll mod = 1000000007; int L, M; string s, t; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> L >> M; vector v; for (int i = 0; i < M; ++i) { int a; cin >> a; v.push_back(a); } sort(v.begin(), v.end()); int sum = 0; int i = 0; while (sum+v[i] < L) { sum += v[i]; i++; } cout << i << endl; return 0; }