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