#include<iostream> #include<string> #include<algorithm> #include<cctype> #include<set> #include<bitset> #include<math.h> #include<map> #include<queue> #include<iomanip> using namespace std; int main(){ int n, m, cnt; cin >> n >> m; vector<int> v(n); for (int i = 0; i < n; i++) cin >> v[i]; sort(v.begin(), v.end()); for (int i = 0; i < n; i++){ if (v[i] <= m){ cnt++; m -= v[i]; } else break; } cout << cnt << endl; }