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