#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  ll N, X;
  cin >> N >> X;
  vector<ll> a;
  for (int i = 0; i < N; ++i) {
    ll t;
    cin >> t;
    a.push_back(t);
  }
  sort(a.begin(), a.end());
  ll x = X;
  int c = 0;
  for (int i = 0; i < N; ++i) {
    if (x >= a[i]) {
      x -= a[i];
      c++;
    } else {
      break;
    }
  }
  cout << c << endl;
  return 0;
}
