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