#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> num(n);
  for (int i = 0; i < n; i++) {
    cin >> num[i];
  }
  sort(num.begin(), num.end());
  int i = 1, sum = num[0];
  while (sum <= x) {
    sum += num[i];
    i++;
  }
  cout << i - 1 << endl;
}
