#include <bits/stdc++.h>
using namespace std;
int main() {
  auto read_string = []() {
    string s;
    cin >> s;
    return s;
  };
  auto read_int = []() {
    int tmp;
    cin >> tmp;
    return tmp;
  };
  auto read_vec_int = [](int count) {
    vector<int> tmp(count);
    for (size_t i = 0; i < count; i++) cin >> tmp[i];
    return tmp;
  };
  int n = read_int(), x = read_int();
  auto vec = read_vec_int(n);
  sort(vec.begin(), vec.end(), less<int>());
  int count = 0;
  for (int c : vec) {
    if ((x - c) >= 0) {
      count++;
      x -= c;
    } else {
      break;
    }
  }
  cout << count << endl;
  return 0;
}
