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