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