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