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