#include <bits/stdc++.h>
using namespace std;
int N, x;
int a;
void solve() {
  int ans;
  cin >> N >> x;
  set<int> s;
  long long sum_a = 0;
  for (int i = 0; i < N; i++) {
    cin >> a;
    s.insert(a);
    sum_a += a;
  }
  if (sum_a < x) {
    ans = N - 1;
  } else {
    ans = 0;
    long long sum_b = 0;
    for (const auto &e : s) {
      sum_b += e;
      if (sum_b <= x) {
        ans++;
      } else {
        break;
      }
    }
  }
  cout << ans << endl;
  return;
}
int main() {
  solve();
  return 0;
}
