#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, x;
  int person = 0;
  vector<int> children;
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    children.push_back(a);
  }
  sort(children.begin(), children.end());
  for (int i : children) {
    x = x - i;
    if (x < 0) {
      break;
    } else {
      person++;
    }
  }
  cout << person;
  return 0;
}
