#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int a[N];
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a, a + N);
  int people = 0;
  int stock = x;
  for (int i = 0; i < N; i++) {
    if (a[i] <= stock) {
      people++;
      stock -= a[i];
    } else {
      break;
    }
  }
  if (stock > 0) people--;
  cout << people << endl;
}
