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