#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using lb = long double;
const int dy[4] = {1, 0, -1, 0};
const int dx[4] = {0, 1, 0, -1};
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}
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;
}
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int lcm(int a, int b) { return a * b / gcd(a, b); }
int two(int n) {
  ll ans = 1;
  for (int i = 0; i < (n); ++i) {
    ans *= 2;
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n, xtrue;
  cin >> n >> xtrue;
  vector<ll> a(n);
  for (int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  sort((a).begin(), (a).end());
  ll ans = 0;
  int x = xtrue;
  for (int i = 0; i < (n); ++i) {
    if (x - a[i] >= 0) {
      x -= a[i];
      ans++;
    } else {
      break;
    }
  }
  if (x == 0 || x == xtrue) {
    cout << ans << "\n", 0;
  } else {
    cout << ans - 1 << "\n", 0;
  }
  return 0;
}
