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