#include <bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      count++;
    }
  }
  if (x != 0) {
    count -= 1;
  }
  if (count == -1) {
    cout << 0 << endl;
  } else {
    cout << count << endl;
  }
  return 0;
}
