#include <bits/stdc++.h>
const int MAX = 1e6 + 3;
long long INF = LLONG_MAX;
const long long MOD = 1e9 + 7;
const double PI = acos(-1);
using namespace std;
bool place(int k, vector<int> &height, int h) {
  priority_queue<int> q;
  for (int i = 0; i < k; i++) {
    q.push(height[i]);
  }
  int curr = 0;
  while (!q.empty()) {
    if (q.size() > 1) {
      int first = q.top();
      q.pop();
      int second = q.top();
      q.pop();
      curr += first;
      if (curr > h) return false;
    } else {
      int first = q.top();
      q.pop();
      curr += first;
      if (curr > h) return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, h;
  cin >> n >> h;
  vector<int> height(n);
  for (int i = 0; i < n; i++) cin >> height[i];
  int ans = 1;
  int low = 1, high = n;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (place(mid, height, h)) {
      ans = mid;
      low = mid + 1;
    } else {
      high = mid - 1;
    }
  }
  cout << ans << endl;
  return 0;
}
