#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (long long i = 0; i < (n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  long long result = 0;
  for (auto c : a) {
    if (c <= x) {
      x -= c;
      result++;
    } else {
      break;
    }
  }
  if (x && result) result--;
  cout << result;
  return 0;
}
