#include <bits/stdc++.h>
int SortAscendNum(const void *num1, const void *num2);
int SortDescendNum(const void *num1, const void *num2);
int main(void) {
  int N, x;
  int A[100];
  unsigned int elmt;
  int i;
  int count = 0;
  scanf("%d %d\n", &N, &x);
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  qsort(A, N, sizeof(*A), SortAscendNum);
  for (i = 0; i < N; i++) {
    if (x >= A[i]) {
      x = x - A[i];
      count++;
    } else
      break;
  }
  if (x != 0 && count != 0) count = count - 1;
  printf("%d\n", count);
  return 0;
}
int SortAscendNum(const void *num1, const void *num2) {
  return *(int *)num1 - *(int *)num2;
}
int SortDescendNum(const void *num1, const void *num2) {
  return *(int *)num2 - *(int *)num1;
}
