#include <bits/stdc++.h>
int asc(const void *a, const void *b) {
  long *A = (long *)a;
  long *B = (long *)b;
  if (*A > *B) return 1;
  if (*A < *B) return -1;
  return 0;
}
int main() {
  int i, j, k = 0, N;
  int x;
  scanf("%d %ld", &N, &x);
  long A[N];
  for (i = 0; i < N; i++) scanf("%ld ", &A[i]);
  qsort(A, N, sizeof(long), asc);
  for (i = 0; i < N; i++) {
    if (x <= A[i]) {
      break;
    }
    x -= A[i];
    k++;
  }
  printf("%d\n", k);
  return 0;
}
