#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;
const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, x;
  cin >> n >> x;
  vi a(n);
  for (int i = 0; i < (n); ++i) cin >> a[i];
  ll sum = 0;
  int i;
  sort(a.begin(), a.end());
  for (i = 0; i < n; i++) {
    sum += a[i];
    if (sum > x) {
      cout << i << endl;
      return 0;
    }
  }
  cout << i << endl;
  return 0;
}
