#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, X, all = 0;
  cin >> N >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    all += A.at(i);
  }
  sort(A.begin(), A.end());
  if (X > all) {
    cout << N - 1 << endl;
  } else if (X < all) {
    int sum = 0;
    while (X > 0) {
      X = X - A.at(sum);
      sum++;
    }
    cout << sum - 1 << endl;
  } else {
    cout << N << endl;
  }
  return 0;
}
