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