#include <bits/stdc++.h>
using namespace std;
template <typename T_char>
T_char ToUpper(T_char cX) {
  return toupper(cX);
}
int main() {
  long long n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    x -= a[i];
    if (x == 0) {
      cnt++;
      break;
    }
    if (x >= a[i]) cnt++;
  }
  cout << cnt << endl;
  return 0;
}
