#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  }
  if (x) ans--;
  cout << max(0, ans) << endl;
}
