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