#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using pii = pair<i64, i64>;
template <class A, class B>
inline bool chmax(A &a, const B &b) {
  return b > a ? a = b, 1 : 0;
}
template <class A, class B>
inline bool chmin(A &a, const B &b) {
  return b < a ? a = b, 1 : 0;
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, x;
  cin >> n >> x;
  vector<int> vec;
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    sum += a;
    vec.push_back(a);
  }
  if (sum == x)
    cout << n << "\n";
  else if (sum < x)
    cout << n - 1 << "\n";
  else {
    sort(vec.begin(), vec.end());
    int res = 0;
    for (auto e : vec) {
      if (e <= x) {
        ++res;
        x -= e;
      }
    }
    cout << res << "\n";
  }
  return 0;
}
