#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1 << 18;
const long long INFLINT = 1LL << 60;
const double PI = acos(-1.0);
struct cinacc {
  cinacc() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
} cinaccc;
struct coutacc {
  coutacc() {
    cout.setf(ios::fixed);
    cout.precision(12);
  }
} coutaccc;
template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
class UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n) {
    for (long long i = 0; i < (long long)(n); i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) { return root(x) == root(y); }
};
int main() {
  int n, x, ans = 0;
  cin >> n >> x;
  vector<int> a(n);
  for (long long i = 0; i < (long long)(n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int i;
  for (i = 0; i < n; i++) {
    x -= a[i];
    if (x < 0) break;
    ans++;
  }
  if (a[i] + x == 0 || ans == 0)
    cout << ans;
  else
    cout << ans - 1;
  return 0;
}
