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