#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a;
  int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    a.push_back(temp);
  }
  std::sort(a.begin(), a.end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    k -= a.at(i);
    if (k < 0)
      break;
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}
