#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, x;
  cin >> N >> x;
  set<long long> as;
  for (long long i = 0; i < N; ++i) {
    long long a;
    cin >> a;
    as.insert(a);
  }
  long long cnt = 0;
  for (long long a : as) {
    if (x < a) {
      break;
    }
    x -= a;
    ++cnt;
  }
  if (x != 0) {
    if (cnt != N) {
    } else if (cnt > 0) {
      cnt -= 1;
    }
  }
  cout << cnt << endl;
  return 0;
}
