#include <bits/stdc++.h>
using namespace std;
long long arr[1005];
vector<long long> vec;
int main() {
  long long n, h;
  cin >> n >> h;
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j <= i; j++) vec.push_back(arr[i]);
    for (long long p = 0; p < vec.size(); p++) vec[p] = arr[p];
    long long k = h;
    sort(vec.begin(), vec.end());
    long long s = vec.size() - 1;
    long long coun = 0;
    while (s >= 0) {
      if (vec[s] <= k) {
        coun++;
        if (s - 1 >= 0) coun++;
      } else
        break;
      k -= vec[s];
      s -= 2;
    }
    ans = max(ans, coun);
    vec.clear();
  }
  cout << ans << endl;
}
