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