#include <bits/stdc++.h>
using namespace std;
const long long LLINF = (1LL << 60);
const long long INF = (1LL << 30);
const double DINF = std::numeric_limits<double>::infinity();
const long long MOD = 1000000007;
long long N, x;
vector<long long> a;
signed main() {
  cin >> N >> x;
  a.assign(N, 0);
  for (long long i = 0; i < N; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  long long ans = 0;
  for (long long i = 0; i < N; ++i) {
    if (x < a[i]) {
      break;
    }
    x -= a[i];
    ans++;
  }
  if (x != 0 && ans != 0) {
    ans--;
  }
  printf("%lld\n", ans);
  return 0;
}
