#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using Graph = vvi;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
using kaage = priority_queue<int, vector<int>, greater<int>>;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
constexpr ll mod = 1e9 + 7;
ll gcd(ll a, ll b) {
  if (a % b == 0) {
    return (b);
  } else {
    return (gcd(b, a % b));
  }
}
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll box(double a) {
  ll b = a;
  return b;
}
ll fff(double a) {
  ll b = a + 0.5;
  return b;
}
ll mch(ll n) {
  if (n == 1)
    return 1;
  else
    return n * mch(n - 1);
}
bool prime(ll a) {
  if (a < 2)
    return false;
  else if (a == 2)
    return true;
  else if (a % 2 == 0)
    return false;
  double m = sqrt(a);
  for (int i = 3; i <= m; i += 2) {
    if (a % i == 0) {
      return false;
    }
  }
  return true;
}
ll modpow(ll a, ll n, ll mod) {
  ll hi = 1;
  while (n > 0) {
    if (n & 1) hi = hi * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return hi;
}
ll mg(ll a, ll mod) { return modpow(a, mod - 2, mod); }
ll num(ll a) {
  string s = to_string(a);
  ll sum = 0;
  for (int j = 0; j < s.size(); ++j) {
    sum += s[j] - '0';
  }
  return sum;
}
vector<bool> seens;
void dfs(const Graph& G, int v) {
  seens[v] = true;
  for (auto next_v : G[v]) {
    if (seens[next_v]) continue;
    dfs(G, next_v);
  }
}
int main() {
  ll n, x;
  cin >> n >> x;
  vl a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] <= x) {
      ans++;
      x -= a[i];
    } else
      break;
  }
  cout << ans << endl;
  return 0;
}
