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