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