#include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ int n, m, cnt; cin >> n >> m; vector 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; }