#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, ans = 0, t = 0;
  cin >> n >> x;
  vector<long> a(n, 0);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) a[i + 1] += a[i];
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) ans++;
    if (a[i] == x) t = 1;
  }
  cout << max(ans - 1 + t, 0) << endl;
  return 0;
}
