#include <bits/stdc++.h>
using namespace std;
int main() {
  long long ans = 0, temp = 0, i = 0, n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int p = 0;
  while (p < n - 1 && x >= a[p]) {
    x -= a[p];
    p++;
  }
  if (p = n - 1 && x == a[p]) p++;
  cout << p << endl;
}
