#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int x;
  vector<int> v;
  cin >> N >> x;
  for (int i = 0; i < N; i++) {
    int num;
    cin >> num;
    v.push_back(num);
  }
  sort(v.begin(), v.end());
  if (accumulate(v.begin(), v.end(), 0) == x) {
    if (x == 0) {
      cout << 0 << endl;
    } else {
      cout << N << endl;
    }
    return 0;
  }
  int rest = x;
  int count = 0;
  for (auto it = v.begin(); it != v.end(); it++) {
    if (rest >= *it) {
      rest -= *it;
      count++;
    }
  }
  if (rest > 0 && count == N) {
    count = N - 1;
  }
  cout << count << endl;
}
