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