#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, x;
  cin >> n >> x;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a.begin() + 1, a.end());
  vector<int> b(n + 1);
  b[0] = 0;
  for (int i = 1; i <= n; i++) {
    b[i] = b[i - 1] + a[i];
  }
  if (b[n] < x) {
    cout << n - 1 << '\n';
    return 0;
  } else if (b[n] == x) {
    cout << n << '\n';
    return 0;
  }
  auto it = upper_bound(b.begin(), b.end(), x);
  int ind = it - b.begin();
  cout << ind - 1 << '\n';
  return 0;
}
