#include <bits/stdc++.h>
using namespace std;
const int N = 1e7 + 100;
const double PI = 3.1415926536;
vector<long long> v;
long long n, m, k, t, sum, r, l, d, b[1111], c, a[1111], p, e;
long long ans;
map<int, string> mp;
bool f;
string s;
queue<long long> q;
bool check(long long x) {
  for (int i = 0; i < n; i++) {
    b[i] = a[i];
  }
  sort(b, b + x);
  long long lastl = m, lastr = m;
  for (int i = x - 1; i >= 0; i -= 2) {
    lastl -= b[i];
    lastr -= b[i];
    if (lastr < 0) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  l = 1;
  r = n;
  while (l <= r) {
    long long mid = (l + r) / 2;
    if (check(mid)) {
      l = mid + 1;
      ans = max(ans, mid);
    } else
      r = mid - 1;
  }
  cout << ans << endl;
  return 0;
}
