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