#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1LL << 60;
template <class T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  for (const auto& x : v) {
    out << x << " ";
  }
  return out;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& x : v) {
    in >> x;
  }
  return in;
}
template <class S, class T>
istream& operator>>(istream& in, pair<S, T>& p) {
  in >> p.first >> p.second;
  return in;
}
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& p) {
  out << '(' << p.first << " ," << p.second << ')';
  return out;
}
int log2i(unsigned long long a) {
  return __builtin_clzll(1) - __builtin_clzll(a);
}
bool check(long long int i, const vector<long long int>& t, long long int h) {
  long long int n = i + 1;
  vector<long long int> a(t.begin(), t.begin() + n);
  sort(a.begin(), a.end(),
       [](const long long int& a, const long long int& b) { return a > b; });
  for (long long int i = 0; i < n; i += 2) {
    h -= a[i];
  }
  return h >= 0;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long int n, h;
  cin >> n >> h;
  vector<long long int> a(n);
  cin >> a;
  long long int s = 0;
  long long int e = n;
  while (s + 1 < e) {
    long long int m = (s + e) / 2;
    if (check(m, a, h)) {
      s = m;
    } else {
      e = m;
    }
  }
  cout << s + 1 << endl;
  return 0;
}
