#include <bits/stdc++.h>
using namespace std;
namespace LCT {
int ch[1][2], fa[1], tag[1], va[1], val[1];
int q[1], top;
int isroot(int x) { return ch[fa[x]][0] != x && ch[fa[x]][1] != x; }
int which(int x) { return ch[fa[x]][1] == x; }
void update(int x) { va[x] = va[ch[x][0]] ^ va[ch[x][1]] ^ val[x]; }
void pushdown(int x) {
  if (!tag[x]) return;
  tag[x] ^= 1;
  tag[ch[x][0]] ^= 1;
  tag[ch[x][1]] ^= 1;
  swap(ch[x][0], ch[x][1]);
}
void rotate(int x) {
  int y = fa[x], z = fa[y], u = which(x), v = u ^ 1;
  if (!isroot(y)) ch[z][which(y)] = x;
  fa[ch[x][v]] = y;
  fa[y] = x;
  fa[x] = z;
  ch[y][u] = ch[x][v];
  ch[x][v] = y;
  update(y);
  update(x);
}
void splay(int x) {
  top = 1;
  q[top] = x;
  for (int i = x; !isroot(i); i = fa[i]) q[++top] = fa[i];
  for (int i = top; i; i--) pushdown(q[i]);
  for (; !isroot(x); rotate(x)) {
    int y = fa[x];
    if (isroot(y)) continue;
    if (which(x) == which(y))
      rotate(y);
    else
      rotate(x);
  }
}
void access(int x) {
  for (int t = 0; x; t = x, x = fa[x]) splay(x), ch[x][1] = t, update(x);
}
void makeroot(int x) {
  access(x);
  splay(x);
  tag[x] ^= 1;
}
int find(int x) {
  access(x);
  splay(x);
  while (ch[x][0]) x = ch[x][0];
  return x;
}
void split(int x, int y) {
  makeroot(x);
  access(y);
  splay(y);
}
void cut(int x, int y) {
  makeroot(x);
  if (find(y) != x || fa[x] != y || ch[x][1]) return;
  fa[x] = 0;
  ch[y][0] = 0;
}
void link(int x, int y) {
  makeroot(x);
  fa[x] = y;
}
}  // namespace LCT
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, h, a[1010], b[1010];
int slove() {
  for (register int i = (1), i__end = (n + 1); i <= i__end; ++i) {
    long long res = 0;
    for (register int j = (1), i__end = (i); j <= i__end; ++j) b[i] = a[i];
    sort(b + 1, b + i + 1);
    for (register int j = (i), i__end = (1); j >= i__end; --j) res += b[j], j--;
    if (res > (long long)h) return printf("%d\n", i - 1), 0;
  }
}
int main() {
  n = read(), h = read();
  for (register int i = (1), i__end = (n); i <= i__end; ++i) a[i] = read();
  a[n + 1] = 2139062143;
  slove();
}
