#include <bits/stdc++.h>
using namespace std;
vector<string> split(const string &s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.push_back(x);
  return v;
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << "[DEBUG] " << it->substr((*it)[0] == ' ', it->length()) << " = " << a
       << '\n';
  err(++it, args...);
}
const int MOD = 1000000007;
template <class T, class U>
inline T tmin(T a, U b) {
  return (a < b) ? a : b;
}
template <class T, class U>
inline T tmax(T a, U b) {
  return (a > b) ? a : b;
}
template <class T, class U>
inline void amax(T &a, U b) {
  if (b > a) a = b;
}
template <class T, class U>
inline void amin(T &a, U b) {
  if (b < a) a = b;
}
template <class T>
T gcd(T a, T b) {
  while (b != 0) {
    T c = a;
    a = b;
    b = c % b;
  }
  return a;
}
int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (int i = (0); i < (n); ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int ans = 0;
  for (int i = (0); i < (n); ++i)
    if (x >= a[i]) {
      x -= a[i];
      ans++;
    }
  if (x > 0) ans--;
  amax(ans, 0);
  cout << ans << endl;
  return 0;
}
