#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  int count = 0;
  for (int i = 0; i < N; i++) {
    x -= A[i];
    if (x >= 0) {
      count++;
      if (i == N - 1)
        if (x != 0) count--;
    }
  }
  cout << count << endl;
}
