#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> v(n);
  for (auto&& u : v) cin >> u;
  sort(begin(v), end(v));
  int sm = 0, cnt = 0;
  for (auto&& u : v) {
    sm += u;
    if (sm <= x)
      cnt++;
    else
      break;
  }
  cout << cnt << endl;
}
