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