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