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