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