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