#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9 + 7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class PalseError {};
class Edge {
 public:
  LL from, to, value;
  Edge(LL a, LL b, LL c) {
    from = a;
    to = b;
    value = c;
  }
  Edge(LL a, LL b) {
    from = a;
    to = b;
  }
};
int main() {
  int(N);
  cin >> (N);
  vector<int> vec;
  int(X);
  cin >> (X);
  for (int a = 0; a < (N); ++a) {
    int(b);
    cin >> (b);
    vec.push_back(b);
  }
  int ans = 0;
  sort((vec).begin(), (vec).end());
  for (int a = 0; a < N; a++) {
    if (X - vec.at(a) >= 0) {
      ans++;
      X -= vec.at(a);
    } else {
      break;
    }
  }
  if (X > 0) {
    ans--;
  }
  if (ans == -1) {
    ans = 0;
  }
  cout << (ans) << endl;
  return 0;
}
