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