#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  long long n, x, tmp;
  vector<long long> v;
  cin >> n >> x;
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> tmp;
    v.push_back(tmp);
  }
  sort((v).begin(), (v).end());
  long long cnt = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    if (x >= v[i]) {
      x -= v[i];
      cnt++;
    }
  }
  if (x == 0 || cnt == 0)
    cout << cnt << endl;
  else
    cout << cnt - 1 << endl;
  return 0;
}
