#include <bits/stdc++.h>
int ans = 0;
int ind_array;
int comp(const void *elem1, const void *elem2) {
  int f = *((int *)elem1);
  int s = *((int *)elem2);
  if (f > s) return 1;
  if (f < s) return -1;
  return 0;
}
void solve(int n, int x, int *array) {
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += array[i];
  }
  if (x < array[0]) {
    return;
  } else {
    for (int i = 0; i < n - 1; i++) {
      array[i] = array[i + 1];
    }
    ind_array++;
    ans++;
    solve(n - 1, x - array[ind_array - 1], array);
  }
}
int main(int argc, char *argv[]) {
  int n = 0;
  int x = 0;
  scanf("%d %d", &n, &x);
  int *a = (int *)calloc(n, sizeof(int));
  int i = 0;
  char tmp;
  do {
    scanf("%d%c", &a[i], &tmp);
    i++;
  } while (tmp != '\n');
  qsort(a, n, sizeof(int), comp);
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += a[i];
  }
  if (x == sum) {
    ans = n;
  } else if (x > sum) {
    ans = n - 1;
  } else {
    solve(n, x, a);
  }
  printf("%d\n", ans);
  return 0;
}
