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