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