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