#include <bits/stdc++.h>
using namespace std;
template <typename P, typename Q>
ostream& operator<<(ostream& os, pair<P, Q> p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "(";
  for (auto& i : v) os << i << ",";
  os << ")";
  return os;
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, x;
  while (cin >> n >> x) {
    vector<int> v(n);
    for (auto& i : v) cin >> i;
    sort(v.begin(), v.end());
    vector<int> u;
    for (auto& i : v) {
      u.push_back(min(x, i));
      x -= i;
    }
    if (x) {
      u.back() += x;
      x = 0;
    }
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      cnt += v[i] == u[i];
    }
    cout << cnt << endl;
  }
  return 0;
}
