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