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