#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int check(vector<long long int> v, long long int k) {
  int count = 0;
  sort(v.rbegin(), v.rend());
  int n = v.size();
  if (n > 1) {
    for (int i = 0; i < n && k > 0; i++) {
      int a = 0, b = 0;
      a = v[i];
      i++;
      if (i < n) b = v[i];
      if (max(a, b) <= k) {
        if (b != 0)
          count += 2;
        else
          count++;
        k -= max(a, b);
      } else if (min(a, b) <= k && b != 0) {
        count++;
        k -= min(a, b);
      } else
        break;
    }
  } else {
    if (v[0] <= k) count++;
  }
  return count;
}
int main() {
  long long int n, k, count = 0, temp;
  cin >> n >> k;
  int arr[n];
  for (int i = 0; i < n; i++) cin >> arr[i];
  vector<long long int> v;
  for (int i = 0; i < n; i++) {
    v.push_back(arr[i]);
    temp = check(v, k);
    count = max(temp, count);
    if (count != v.size()) break;
  }
  cout << count;
}
