#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;
int main() {
  int n, x, index = 0, sum = 0;
  cin >> n >> x;
  sum = x;
  vector<int> child(n);
  vector<int> snake_child(n);
  for (int i = 0; i < (int)(n); i++) cin >> child[i];
  sort(child.begin(), child.end());
  for (int i = 0; i < (int)(n); i++) {
    if (x >= child[i])
      x -= child[i];
    else
      break;
    index++;
  }
  if (sum >= child[0] && x > 0) index--;
  cout << index << endl;
  return 0;
}
