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