#include <bits/stdc++.h>
using namespace std;
using vl = vector<long long>;
using vvl = vector<vl>;
constexpr int MOD = 1000000007;
using long long = long long;
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
void print(const std::vector<int> &v) {
  std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
  std::cout << std::endl;
}
int main() {
  int N;
  long long x;
  cin >> N >> x;
  vector<long long> a(N);
  for (long long i = 0; i < (long long)N; i++) {
    cin >> a[i];
  }
  long long s = accumulate(a.begin(), a.end(), 0LL);
  if (s < x) {
    cout << N - 1 << endl;
  }
  if (s == x) {
    cout << N << endl;
  }
  sort(a.begin(), a.end());
  int cnt = 0;
  for (long long i = 0; i < (long long)N; i++) {
    x -= a[i];
    if (x >= 0) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}
