#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int n,m,r;
long long a[1005];
long long b[1005];
bool cmp(int a,int b){
return a>b;
}
void f(int left,int right){
if(left>right) return;
for(int i=1;i<=n;i++){
b[i]=a[i];
}
int mid=(left+right)/2;
sort(b+1,b+mid+1,cmp);
long long cnt=0;
for(int i=1;i<=mid;i+=2){
cnt+=b[i];
}
if(cnt>m) f(left,mid-1);
else{
r=mid;
f(mid+1,right);
}
}
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>a[i];
b[i]=a[i];
}
f(1,n);
cout<<r<<endl;
}