#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n >> a;
  vector<int> b(n);
  for (int i = 0; i < n; ++i) {
    cin >> b.at(i);
  }
  sort(b.begin(), b.end());
  int count = 0;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += b.at(i);
    if (sum > a) break;
    count++;
  }
  cout << count << endl;
}
