#include <bits/stdc++.h>
int main() {
  int N, x, i, j, count = 0, temp;
  scanf("%d %d", &N, &x);
  int A[N + 1];
  for (i = 0; i < N; i++) {
    scanf("%d", &A[i]);
  }
  for (i = 0; i < N; i++) {
    for (j = i + 1; j < N; j++) {
      if (A[j] < A[i]) {
        temp = A[i];
        A[i] = A[j];
        A[j] = temp;
      }
    }
  }
  if (x > A[0])
    for (i = 0; x != 0; i++) {
      if (A[i] <= x) {
        if (N >= count) count++;
        if (N < count) count = N - 1;
        x = x - A[i];
        printf("value %d\n", x);
      }
    }
  printf("%d\n", count);
  return 0;
}
