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