#include <bits/stdc++.h>
using namespace std;
int N, X;
vector<int> A;
int sum = 0;
int ans = 0;
int calc() {
  if (X > sum) return N - 1;
  if (X == sum) return N;
  for (int i = 0; i < N; i++) {
    if (X >= A[i]) {
      ans++;
      X -= A[i];
    } else
      break;
  }
  return ans;
}
int main() {
  cin >> N >> X;
  A.resize(N);
  for (int &a : A) {
    cin >> a;
    sum += a;
  }
  sort(A.begin(), A.end());
  cout << calc() << endl;
  return 0;
}
