#include <bits/stdc++.h>
#pragma GCC optimize("-O2")
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " = " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
const long double PI = acos(-1.0);
const int INF = 0x3f3f3f3f;
void solve() {
  long long n, x;
  cin >> n >> x;
  long long a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x - a[i] < 0)
      break;
    else
      ans++, x -= a[i];
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int t;
  t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
