#include <bits/stdc++.h>
using namespace std;
int main() {
  long long total, x, tmp;
  cin >> total >> x;
  vector<long long> number(total);
  for (int i = 0; i < total; i++) {
    cin >> number[i];
  }
  for (int i = 0; i < total; ++i) {
    for (int j = i + 1; j < total; ++j) {
      if (number[i] > number[j]) {
        tmp = number[i];
        number[i] = number[j];
        number[j] = tmp;
      }
    }
  }
  long long 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) {
      break;
    }
  }
  cout << counter << endl;
  return 0;
}
