#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N;
  long long x;
  cin >> N >> x;
  vector<int> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  int count = 0;
  int res = 0;
  for (int i = 0; i < N; i++) {
    res += v[i];
    if (res > x) {
      break;
    } else {
      count += 1;
    }
  }
  cout << count << endl;
  return 0;
}
