#include <bits/stdc++.h>
using namespace std;
int child_count, candy;
vector<int> child;
int main(int argc, char const* argv[]) {
  cin >> child_count;
  cin >> candy;
  int input;
  for (int i = 0; i < child_count; i++) {
    cin >> input;
    child.push_back(input);
  }
  sort(child.begin(), child.end());
  int child_sat = 0;
  for (auto& i : child) {
    candy -= i;
    if (candy >= 0) {
      child_sat++;
    } else {
      break;
    }
  }
  cout << child_sat;
  return 0;
}
