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