#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (x >= a.at(i)) {
      res++;
      x -= a.at(i);
      if (x <= 0) {
        break;
      }
    }
  }
  if (res > 0 && x > 0) {
    res--;
  }
  cout << res << endl;
  ;
}
