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