#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < (int)(N); i++) {
    cin >> a.at(i);
  }
  if (accumulate(a.begin(), a.end(), 0) < x) {
    cout << N - 1 << endl;
    return 0;
  }
  sort(a.begin(), a.end());
  int cnt = 0;
  int dist = 0;
  int j = 0;
  while (j <= N - 1 && dist + a.at(j) <= x) {
    cnt++;
    dist += a.at(j);
    j++;
  }
  cout << cnt << endl;
}
