#include<bits/stdc++.h>
using namespace std;
const int N=1010;
int n,m,f[N][N],v[N],w[N];
int main(){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>v[i]>>w[i];
}
for(int i=n;i>=1;i--){
for(int j=0;j<=m;j++){
f[i][j]=f[i+1][j];
if(j>=v[i])f[i][j]=max(f[i+1][j-v[i]]+w[i],f[i][j]);
}
}
int maxx=m;
for(int i=1;i<=n;i++){
if(i==n&&maxx>=v[i]){
cout<<i<<endl;
break;
}
if(maxx<=0)break;
if(maxx-v[i]>=0&&f[i][maxx]==f[i+1][maxx-v[i]]+w[i]){
cout<<i<<" ";
maxx-=v[i];
}
}
}