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