#include <bits/stdc++.h>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printe(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printew(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...) {}
template <ostream& out = cout, class... T>
void printdu(T&&...){};
template <class S, class T>
istream& operator>>(istream& in, pair<S, T>& p) {
  return in >> p.first >> p.second;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& e : v) {
    in >> e;
  }
  return in;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<int> as(n);
  cin >> as;
  sort(as.begin(), as.end());
  int cnt = 0;
  while (cnt < n && x >= as[cnt]) {
    x -= as[cnt];
    cnt++;
  }
  if (x && cnt) {
    cnt--;
  }
  cout << cnt << '\n';
}
