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