#include <bits/stdc++.h>
using namespace std;
const long long LINF = 1001002003004005006ll;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n;
  long long x;
  cin >> n >> x;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n);
  if (a[0] > x) {
    cout << 0 << endl;
    return 0;
  }
  int ind = 0;
  while (x > 0 && ind < n) {
    x -= a[ind];
    ind++;
  }
  if (ind == n && x > 0) {
    cout << n - 1 << endl;
  } else {
    cout << ind << endl;
  }
  return 0;
}
