#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a, b, c, d, m, n, maxi = 0, f = 0, mini = 1000000000, sum = 0;
  string str, str2;
  long long x;
  cin >> n >> x;
  vector<long long> v(n);
  for (long long i = (long long)(0); i < (long long)(n); i++) cin >> v[i];
  sort(v.begin(), v.end());
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    sum += v[i];
    if (sum <= x) f++;
  }
  cout << f << endl;
  return 0;
}
