#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
int main() {
  int n;
  long x;
  cin >> n >> x;
  vector<long> a(n);
  for (int i = 0; i < (int)(n); i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  long ans = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (x >= a.at(i)) {
      ans++;
      x -= a.at(i);
    } else
      break;
  }
  cout << ans << endl;
}
