#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    int n, m, i, j, k;
    cin >> n >> k;
    int a[n];
    for (i = 0; i < n; i++) cin >> a[i];
    multiset<int, greater<int>> s;
    multiset<int, greater<int>>::iterator ii;
    m = 0;
    for (i = 0; i < n; i++) {
      s.insert(a[i]);
      j = k;
      for (ii = s.begin(); ii != s.end(); ii++) {
        j -= *ii;
        if (j < 0) break;
        ii++;
        if (ii == s.end()) break;
      }
      if (ii == s.end()) m = i + 1;
    }
    cout << m << endl;
  }
}
