#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());
  int i = 0;
  while (x > 0 && i < n) {
    if (a[i] <= x)
      x -= a[i];
    else
      break;
    i++;
  }
  if (x)
    cout << i - 1;
  else
    cout << i;
}
