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