#include <bits/stdc++.h>
const int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long n, x;
  cin >> n >> x;
  vector<long long> v(n);
  for (long long i = 0; i < long long(n); ++i) cin >> v[i];
  sort((v).begin(), (v).end());
  for (long long i = 0; i < long long(n - 1); ++i) {
    if (x < v[i]) {
      cout << i << endl;
      return 0;
    }
    x -= v[i];
  }
  if (x == v.back()) {
    cout << n << endl;
  } else {
    cout << n - 1 << endl;
  }
}
