#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long long int num;
  cin >> N >> num;
  int count = 0;
  long long int co = 0;
  long long int b;
  vector<long long int> a;
  for (int i = 0; i < N; i++) {
    cin >> b;
    a.push_back(b);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    co += a[i];
    if (co < num) {
      count++;
    } else {
      break;
    }
  }
  if (co < num) {
    count--;
  }
  cout << count << endl;
}
