#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 cnt = 0;
  bool flagNext = false;
  bool flagExit = false;
  int itemp;
  for (int i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      cnt++;
      itemp = i;
    }
  }
  if (cnt == 0) {
    cout << 0 << endl;
  } else if (x == 0) {
    cout << cnt << endl;
  } else {
    cnt--;
    x += a[itemp];
    for (int j = itemp + 1; j < n; j++) {
      if (x == a[j])
        ;
      cnt++;
    }
    cout << cnt;
  }
  return 0;
}
