#include <bits/stdc++.h>
int compare_int(const void *a, const void *b) { return *(int *)a - *(int *)b; }
int main() {
  int N, i, x, count = 0;
  int *a;
  scanf("%d %d", &N, &x);
  a = (int *)malloc(sizeof(int) * N);
  for (i = 0; i < N; i++) scanf("%d ", &a[i]);
  qsort(a, N, sizeof(int), compare_int);
  for (i = 0; i < N; i++) {
    x -= a[i];
    if (x < 0) break;
    count++;
  }
  printf("%d", count);
  return 0;
}
