#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long n, x;
  cin >> n >> x;
  vector<long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  vector<long> sum(n + 2);
  for (int i = 1; i <= n; i++) {
    sum[i] += sum[i - 1] + a[i - 1];
  }
  sum[n + 1] = 10e9 * 2 + 1;
  for (int i = 0; i <= n + 1; i++) {
    if (sum[i] > x) {
      cout << i - 1 << endl;
      break;
    }
  }
}
