#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<long long, long long>;
using vint = vector<long long>;
using vvint = vector<vint>;
using vpint = vector<pint>;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
void put_double(T a) {
  if (cout.precision() != 12) cout << setprecision(12);
  cout << a << endl;
}
template <class T>
void print(T a) {
  cout << a << endl;
}
signed main(void) {
  long long n, x;
  cin >> n >> x;
  vint a(n);
  for (long long((i)) = (0), TemPNuM = (long long)(((a).size()));
       ((i)) < TemPNuM; ++((i)))
    cin >> (a)[i];
  ;
  sort((a).begin(), (a).end());
  long long ans = 0;
  for (auto &(ai) : (a)) {
    if (x >= ai) {
      x -= ai;
      ans++;
    }
  }
  if (ans > 0 && x > 0) ans--;
  print(ans);
  return 0;
}
