#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 peop = 0;
  for (int i = 0; x < a[i]; ++i) {
    if (x >= a[i]) {
      x = x - a[i];
      peop = peop + 1;
    }
  }
  if (x != 0) --peop;
  cout << peop << endl;
}
