#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }
  sort(a.begin(), a.end());
  int count = 0;
  for (int i = 0; i < n; i++) {
    x -= a.at(i);
    if (x >= 0) {
      count++;
    }
  }
  if (x > 0) {
    cout << n - 1 << endl;
  } else {
    cout << count << endl;
  }
}
