#include <bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
using f64 = double;
constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;
void solve() {
  i64 n, x;
  cin >> n >> x;
  vector<i64> a(n);
  for (auto& e : a) cin >> e;
  sort(begin(a), end(a));
  i64 ans = 0;
  for (auto& e : a) {
    if (x < e) break;
    ans++, x -= e;
  }
  cout << ans - (ans != 0 && x != 0) << endl;
}
int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  solve();
}
