#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}
using ll = long long;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> vec(n);
  cin >> vec;
  sort(vec.begin(), vec.end());
  int sum = 0;
  int ans = 0;
  for (int i = 0; i < (n); ++i) {
    sum += vec[i];
  }
  if (sum == x) {
    cout << n << endl;
    return 0;
  }
  sum = 0;
  bool flag = false;
  for (int i = 0; i < (n); ++i) {
    sum += vec[i];
    if (sum >= x) {
      break;
      flag = true;
    }
    ans++;
  }
  if (sum < x && !flag) {
    ans--;
  }
  cout << ans << endl;
  return 0;
}
