#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, x, sum = 0, cnt = 0;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0; i < (long long)(N); i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  bool flag = true;
  for (long long i = 0; i < (long long)(N); i++) {
    if (a[0] > x) {
      flag = false;
      break;
    }
    if (x > sum) {
      sum += a[i];
      cnt++;
    } else {
      break;
    }
  }
  if (x - sum > 0 && flag) {
    cnt -= 1;
  }
  cout << cnt << endl;
}
