#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];
  int ans = 0;
  sort(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i];
    if (sum <= x) ++ans;
  }
  if (sum == x)
    cout << n << endl;
  else
    cout << n - 1 << endl;
  return 0;
}
