#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  long long x = 0;
  cin >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int now = 0;
  int ans = 0;
  while (x > 0 && now < n) {
    if (a.at(now) <= x) {
      ans++;
      x -= a.at(now);
    } else
      break;
    now++;
  }
  if (x > 0) ans--;
  cout << ans << endl;
  return 0;
}
