#include <bits/stdc++.h>
using namespace std;
long long n, x, s[110000], asn = 0;
int main() {
  cin >> n >> x;
  for (long long i = 0; i < n; i++) cin >> s[i];
  sort(s, s + n);
  for (long long i = 0; i < n; i++) {
    if (x >= s[i]) {
      asn++;
      x -= s[i];
    }
  }
  if (x != 0) asn = max(0ll, asn - 1);
  cout << asn << endl;
}
