#include <bits/stdc++.h>
using namespace std;
vector<long long> vec;
int main() {
  long long n, x;
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    int tmp = 0;
    cin >> tmp;
    vec.push_back(tmp);
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    x = x - vec[i];
    if (x > 0) {
      ans++;
    } else {
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
