#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const double EPS = (double)1e-9;
const double pi = acos(-1.0);
const int MAXN = 2e6 + 5;
int n;
long long a[MAXN], x;
int main() {
  cin >> n >> x;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  sort(a + 1, a + 1 + n);
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (i == n) {
      if (a[i] == x) res++;
      continue;
    }
    if (a[i] <= x) {
      x -= a[i];
      res++;
    }
  }
  cout << res;
  return 0;
}
