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