#include <bits/stdc++.h>
void merge(int *a, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  int L[n1 + 1], R[n2 + 1];
  int i;
  for (i = 0; i < n1; i++) {
    L[i] = a[left + i];
  }
  for (i = 0; i < n2; i++) {
    R[i] = a[mid + i];
  }
  L[n1] = 2147483647;
  R[n2] = 2147483647;
  int j = 0, k = 0;
  for (i = left; i < right; i++) {
    if (L[j] < R[k]) {
      a[i] = L[j];
      j++;
    } else {
      a[i] = R[k];
      k++;
    }
  }
}
void merge_sort(int *a, int left, int right) {
  int middle;
  if (left + 1 < right) {
    middle = (left + right) / 2;
    merge_sort(a, left, middle);
    merge_sort(a, middle, right);
    merge(a, left, middle, right);
  }
}
int main(void) {
  int n, x;
  scanf("%d %d", &n, &x);
  int a[n];
  int i;
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  merge_sort(a, 0, n);
  int now = x, counter = 0;
  for (i = 0; i < n; i++) {
    now -= a[i];
    if (now >= 0) {
      counter++;
    }
  }
  if (now > 0) {
    counter--;
  }
  printf("%d\n", counter);
  return 0;
}
