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