#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e6 + 123;
const long long INF = (long long)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;
void megaRandom() {
  unsigned int FOR;
  asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}
int n, a[N], x;
int main() {
  megaRandom();
  scanf("%d %d", &n, &x);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  sort(a + 1, a + n + 1);
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (x >= a[i]) {
      res++;
      x -= a[i];
    }
  }
  if (x > 0) res--;
  res = max(res, 0);
  printf("%d\n", res);
  return 0;
}
