#include <bits/stdc++.h>
using namespace std;
string Yes(bool b) {
  if (b) {
    return "Yes";
  } else {
    return "No";
  }
}
string YES(bool b) {
  if (b) {
    return "YES";
  } else {
    return "NO";
  }
}
int a = 0, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort((a).begin(), (a).end());
  for (int i = 1; i < n; i++) {
    a[i] += a[i - 1];
  }
  if (a[n - 1] < x)
    cout << n - 1 << endl;
  else if (a[n - 1] == x)
    cout << n << endl;
  else {
    for (int i = 0; i < n; i++) {
      if (a[i] > x) {
        n = i;
        break;
      }
    }
    cout << n << endl;
  }
  return 0;
}
