#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int x;
  cin >> x;
  vector<int> a(n);
  for (int& aa : a) cin >> aa;
  sort(a.begin(), a.end());
  int ans = 0;
  for (int aa : a) {
    if (x >= aa) {
      ans++;
      x -= aa;
    }
  }
  if (x && ans) ans--;
  cout << ans << endl;
  return 0;
}
