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