#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
void solve() {}
int main() {
  ll n, 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 (x >= a[i]) {
      num++;
      x -= a[i];
    }
  }
  if (x > 0 && num > 0) {
    num--;
  }
  cout << num << endl;
  return 0;
}
