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