#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  int x;
  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 if (sum < x) {
    answer = N - 1;
  } else {
    sort(a.begin(), a.end());
    answer = 0;
    while (x >= a.at(answer)) {
      x -= a.at(answer);
      answer++;
    }
  }
  cout << answer << endl;
  return 0;
}
