#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
const int MAX = 200020;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1 << 29;
const long long INFL = 1e18;
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
void solve(void) {
  long long N, x;
  cin >> N >> x;
  vector<long long> as(N);
  for (int i = 0; i <= N - 1; i++) {
    cin >> as[i];
  }
  sort((as).begin(), (as).end());
  long long ans = 0, i = 0;
  while (x > 0 && i < N) {
    x -= as[i];
    ans++;
    i++;
  }
  if (x != 0LL && i == N) {
    ans--;
  }
  cout << ans << endl;
}
int main(void) {
  solve();
  return 0;
}
