#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < (n); i++) cin >> a[i];
  sort(a.begin(), a.end());
  int res = 0;
  if (a[0] > x) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < (n); i++) {
    if (x >= a[i]) x -= a[i], res++;
  }
  if (x != 0) res--;
  cout << res << endl;
  return 0;
}
