#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;
  int out = 0;
  for (int i = 0; i < N; i++) {
    sum += a.at(i);
    if (sum > x) {
      out = i;
      break;
    } else if (sum == x && i == N - 1) {
      out = N;
      break;
    } else if (sum == x && i < N - 1) {
      out = N - 1;
      break;
    }
  }
  cout << out << endl;
}
