#include <bits/stdc++.h>
using namespace std;
const long long inf = numeric_limits<long long>::max();
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> v(n);
  for (long long i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    if (v[i] > x) {
      res = i;
      break;
    } else {
      if (v[i] == x) {
        res = i + 1;
        break;
      }
      x -= v[i];
    }
  }
  cout << res << endl;
}
