#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  ll x;
  cin >> x;
  ll a[n];
  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  for (ll i = 0; i < n; i++) {
    if (x >= a[i]) {
      x -= a[i];
      cnt++;
    } else {
      break;
    }
  }
  if (x > 0)
    cout << cnt - 1 << endl;
  else
    cout << cnt << endl;
}
