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