#include <bits/stdc++.h>
using namespace std;
using llong = long long;
using P = pair<llong, llong>;
const llong inf = llong(1e18) + 7;
const llong mod = 1e9 + 7;
int main() {
  llong N, x;
  vector<llong> a;
  cin >> N >> x;
  a.resize(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  llong sum = 0;
  int i;
  for (i = 0; i < N && sum < x; i++) sum += a[i];
  if (i == N && sum != x) i--;
  if (a[0] > x) i = 0;
  cout << i << endl;
  return 0;
}
