#include <bits/stdc++.h>
unsigned long long int N, X;
unsigned long long int sort[101];
unsigned long long int buffer[100];
void mergeSort(unsigned long long int n, unsigned long long int x[]) {
  unsigned long long int i, j, k, m;
  if (n <= 1) {
    return;
  }
  m = n / 2;
  mergeSort(m, x);
  mergeSort(n - m, x + m);
  for (i = 0; i < m; i++) {
    buffer[i] = x[i];
  }
  j = m;
  i = k = 0;
  while (i < m && j < n) {
    if (buffer[i] <= x[j]) {
      x[k++] = buffer[i++];
    } else {
      x[k++] = x[j++];
    }
  }
  while (i < m) {
    x[k++] = buffer[i++];
  }
}
unsigned long long int ans = 0;
int main() {
  scanf("%llu %llu", &N, &X);
  for (unsigned long long i = 0; i < N; i++) {
    scanf("%llu", &sort[i]);
  }
  mergeSort(N, sort);
  unsigned long long int sum = 0;
  sort[N] = X + 1;
  for (int i = 0; i < N + 1; i++) {
    sum += sort[i];
    if (X < sum) {
      printf("%d\n", i);
      return 0;
    }
  }
  printf("%d\n", N - 1);
  return 0;
}
