#include <bits/stdc++.h>
using namespace std;
int main() {
  long int n, count = 0, x;
  long int num[1500000000];
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  sort(num, num + 15000000000);
  for (int j = 0; j < n; j++) {
    x -= num[j];
    if (x >= 0)
      count++;
    else
      break;
  }
  cout << count << endl;
}
