#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int n, k, x, a[N];
long long s;
template <class T>
ostream& operator<<(ostream& out, vector<T> v) {
  out << v.size() << '\n';
  for (auto e : v) out << e << ' ';
  return out;
}
template <class T1, class T2>
ostream& operator<<(ostream& out, pair<T1, T2> p) {
  return out << '(' << p.first << ' ' << p.second << ')';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> x;
  int s = 0;
  for (int i = 1; i <= n; i++) cin >> a[i], s += a[i];
  if (s == x) return cout << n << '\n', 0;
  sort(a + 1, a + n + 1);
  s = 0;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    s += a[i];
    if (x >= s) ans = i;
  }
  cout << min(ans, n - 1) << '\n';
}
