#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int N;
  ll x;
  cin >> N >> x;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < N; i++) {
    x -= a.at(i);
    if (x < 0) {
      cout << i << endl;
      return 0;
    }
  }
  cout << N << endl;
}
