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