#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;
  }
  int count;
  if (sum == x) {
    count = N;
  } else {
    count = 0;
    sort(s.begin(), s.end());
    for (int i = 0; i < N; i++) {
      x -= s.at(i);
      if (x >= 0) {
        count++;
        if (count == N) {
          count = N - 1;
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}
