#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int x;
  cin >> n >> x;
  long long int *a = new long long int[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  int count = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      count++;
      x -= a[i];
    }
  }
  if (x > 0) count--;
  cout << count << endl;
  delete[] a;
  return 0;
}
