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