#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  int num = 0;
  for (int i = 0; i < n; ++i) {
    if (a[i] <= x) {
      x -= a[i];
      ++num;
    }
  }
  if (0 < x && 0 < num) --num;
  cout << num << endl;
  return 0;
}
