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