#include <bits/stdc++.h>
void sort_N(int *x, int n);
int main() {
  int i, n, x, *ary;
  int counter = 0;
  scanf("%d", &n);
  scanf("%d", &x);
  ary = (int *)calloc(n, sizeof(int));
  if (ary == NULL) {
    return 0;
  }
  for (i = 0; i < n; i++) {
    scanf("%d", &ary[i]);
  }
  sort_N(ary, n);
  for (i = 0; i < n; i++) {
    if (x >= ary[i]) {
      counter++;
      x -= ary[i];
    }
  }
  if (x > 0 && counter != 0) {
    counter--;
  }
  printf("%d", counter);
  free(ary);
  return 0;
}
void sort_N(int *x, int n) {
  int i, j, fake;
  for (i = 0; i < n - 1; i++) {
    for (j = 0; j < n - 1; j++) {
      if (x[j] > x[j + 1]) {
        fake = x[j];
        x[j] = x[j + 1];
        x[j + 1] = fake;
      }
    }
  }
}
