#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, x;
  cin >> n >> x;
  vector<int> vec(n);
  int cou = 0;
  for (int i = 0; i < (int)(n); i++) {
    cin >> vec.at(i);
    if (vec.at(i) > x) cou++;
  }
  bool flag = false;
  if (cou == n) flag = true;
  sort(vec.begin(), vec.end());
  int count = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (x - vec.at(i) >= 0) {
      x = x - vec.at(i);
      count++;
    } else {
      break;
    }
  }
  if (x > 0) {
    count -= 1;
  }
  if (flag == false) {
    cout << count << endl;
  }
  if (flag == true) {
    cout << 0 << endl;
  }
}
