#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int L, N; cin >> L >> N; vector W(N); for (int i = 0; i < N; i++) { cin >> W[i]; } sort(W.begin(), W.end()); int res = 0; for (int i = 0; i < N; i++) { L -= W[i]; if (L < 0) break; res++; } cout << res << '\n'; return 0; }