#include <bits/stdc++.h>
void bubbleSort(long long int arr[], int n) {
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - i - 1; j++) {
      if (arr[j] > arr[j + 1]) {
        int swap = arr[j];
        arr[j] = arr[j + 1];
        arr[j + 1] = swap;
      }
    }
  }
}
int main() {
  int n, k, ans;
  scanf("%d %d", &n, &k);
  long long int arr[n];
  for (int i = 0; i < n; i++) {
    scanf("%lld", &arr[i]);
    bubbleSort(arr, i + 1);
    int j = i;
    long long int sum = 0;
    while (j > -1) {
      sum += arr[j];
      j -= 2;
    }
    if (sum <= k) {
      ans = i + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
