#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long int x;
  scanf("%d %lld\n", &n, &x);
  long long int a[105] = {};
  for (int i = 0; i < (int)(n); i++) scanf("%lld", &a[i]);
  sort(a, a + n);
  int poi = -1;
  while (x >= 0 && poi < n - 1) {
    poi++;
    x -= a[poi];
    if (x < 0) poi--;
  }
  printf("%d\n", poi + 1);
  return 0;
}
