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