#define _USE_MATH_DEFINES #define _CRT_SECURE_NO_WARNINGS #include "bits/stdc++.h" #define rep(i,n) for(int i = 0;i < n;i++) #define REP(i,n,k) for(int i = n;i < k;i++) #define P(p) cout<<(p)<> ret; return ret; } ll gcd(ll a, ll b){ if (b > a)swap(a, b); if (b == 0) return a; return gcd(b, a%b); } void solve() { int size, n; cin >> size >> n; vector v; int sum = 0; rep(i, n){ int a; cin >> a; sum += a; v.push_back(a); } if (sum == size){ P(n); return; } sort(v.begin(), v.end()); int count = 0; int i = 0; while(i != v.size()){ if (v[i] <= size){ size -= v[i]; i++; count++; } else{ break; } } P(count); } int main() { solve(); return 0; }