#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(), less<int>());
  int ans = 0;
  for (auto i = a.begin(); i != a.end(); ++i) {
    x -= *i;
    if (x >= 0) ans++;
  }
  cout << (x > 0 ? ans - 1 : ans) << "\n";
}
