#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  int a[n];
  for (int k = 0; k < n; k++) {
    cin >> a[k];
  }
  sort(a, a + n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) {
      count++;
      x = x - a[i];
    } else
      break;
  }
  if (x != 0 && count != 0) count--;
  cout << count << endl;
}
