#include <bits/stdc++.h>
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  ll x;
  cin >> n >> x;
  ll* a = new ll[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]) {
      ++ans;
      x -= a[i];
    } else {
      break;
    }
  }
  cout << ans << "\n";
  return 0;
}
