#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
const int MOD = 1e9 + 7;
const ll INF = 2e15;
template <class T>
void print(const T& t) {
  cout << t << endl;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  ll n, x;
  cin >> n >> x;
  vl a(n);
  for (ll i = 0; i < (ll)(n); i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll snuck = x;
  ll count = 0;
  for (ll i = 0; i < (ll)(n); i++) {
    snuck -= a[i];
    if (snuck >= 0) {
      count++;
    }
  }
  if (snuck != 0) {
    count--;
  }
  print(count);
}
