#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 count = 0;
  for (auto i = a.begin(); i != a.end(); i++) {
    if (x < *i) break;
    x -= *i;
    count++;
  }
  if (x > 0) count--;
  count = max(count, 0);
  cout << count << endl;
}
