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