#define ll long long #define ffor(i,a,b) for (int i=(a);i<(b);i++) #define rfor(i,a,b) for (int i=(b)-1;i>=(a);i--) #define rep(i,n) for (int i=0;i<(n);i++) #define rrep(i,n) for (int i=(n)-1;i>=0;i--) #include #include #include #include #include #include #include #include #define SIZE 100001 #define MOD 1000000007 #define INF 100000000 using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); int l,n; int w[SIZE]; cin >> l; cin >> n; rep(i,n) cin >> w[i]; sort(w,w + n); int count = 0; rep(i,n){ l -= w[i]; if(l <0) break; count++; } cout << count << endl; return 0; }