#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int &x : a) {
    cin >> x;
  }
  sort(a.begin(), a.end());
  int count = 0;
  int remain = x;
  for (int x : a) {
    remain -= x;
    if (remain >= 0) {
      count++;
    }
  }
  if (remain > 0) {
    count--;
  }
  cout << count << endl;
}
