#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++) {
    if (v[i] > x) break;
    x -= v[i];
    count += 1;
  }
  cout << count << endl;
  return 0;
}
