//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 0;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l <= r) {
        long long m = (l + r)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        auto mid = lower_bound(data.begin(), data.end(), m, cmpl);
        if (mid != data.end()) {

            vector<el> tmp(++mid, data.end());
            if (tmp.size() < m - 1) {
                r = m - 1;
                continue;
            }
            sort(tmp.begin(), tmp.end(), cmp2);
            long long tmpsum = (--mid)->t;
            for(int i = 0; i < m - 1; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok
                if (m  > ans) {
                    //ok

                    ans = m;
                }
                l = m + 1;
            } else {
                r = m - 1;
            }

        }

    }
    if (ans) {
        auto mid = lower_bound(data.begin(), data.end(), ans, cmpl);
        ansInd.push_back(mid->ind);

        vector<el> tmp(++mid, data.end());
        sort(tmp.begin(), tmp.end(), cmp2);
        for(int i = 0; i < ans - 1; ++i) {
            ansInd.push_back(tmp[i].ind);
        }
    }

    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 1;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l < r) {
        long long m = (l + r + 1)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        vector<el> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= m) {
                tmp.push_back(data[i]);
            }
        }
        sort(tmp.begin(), tmp.end(), cmp2);
        if (tmp.size() < m) {
            r = m - 1;
            continue;
        }
        long long tmpsum = 0;
            for(int i = 0; i < m; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok
                if (m  > ans) {
                    //ok

                    ans = m;
                }
                l = m;
            } else {
                r = m - 1;
            }

    }
    if (ans) {
        vector<long long> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= ans) {
                tmp.push_back(data[i].ind);
            }
        }
        sort(tmp.begin(), tmp.end());

        for(int i = 0; i < ans; ++i) {
            ansInd.push_back(tmp[i]);
        }
    }
    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 1;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l < r) {
        long long m = (l + r)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        auto mid = lower_bound(data.begin(), data.end(), m, cmpl);
        if (mid != data.end()) {
            m = mid->a;
            vector<el> tmp(++mid, data.end());
            sort(tmp.begin(), tmp.end(), cmp2);
            long long tmpsum = (--mid)->t;
            for(int i = 0; i < m - 1; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok
                if (m > ans) {
                    //ok

                    ans = m;
                }
                l = m + 1;
            } else {
                r = m - 1;
            }

        }

    }
    if (ans) {
        auto mid = lower_bound(data.begin(), data.end(), ans, cmpl);
        ansInd.push_back(mid->ind);

        vector<el> tmp(++mid, data.end());
        sort(tmp.begin(), tmp.end(), cmp2);
        for(int i = 0; i < ans - 1; ++i) {
            ansInd.push_back(tmp[i].ind);
        }
    }

    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 1;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l < r) {
        long long m = (l + r)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        auto mid = lower_bound(data.begin(), data.end(), m, cmpl);
        if (mid != data.end()) {
            m = mid->a;
            vector<el> tmp(++mid, data.end());
            sort(tmp.begin(), tmp.end(), cmp2);
            long long tmpsum = (--mid)->t;
            for(int i = 0; i < m - 1; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok
                if (m > ans) {
                    //ok

                    ans = m;
                    ansInd.clear();
                    ansInd.push_back(mid->ind);
                    for(int i = 0; i < m - 1; ++i) {
                        ansInd.push_back(tmp[i].ind);
                    }
                }
                l = m + 1;
            } else {
                r = m - 1;
            }

        }

    }
    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 1;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l <= r) {
        long long m = (l + r)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        auto mid = lower_bound(data.begin(), data.end(), m, cmpl);
        if (mid != data.end()) {
            m = mid->a;
            vector<el> tmp(++mid, data.end());
            sort(tmp.begin(), tmp.end(), cmp2);
            long long tmpsum = (--mid)->t;
            for(int i = 0; i < m - 1; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok
                if (m > ans) {
                    //ok

                    ans = m;
                }
                l = m + 1;
            } else {
                r = m - 1;
            }

        }

    }
    if (ans) {
        auto mid = lower_bound(data.begin(), data.end(), ans, cmpl);
        ansInd.push_back(mid->ind);

        vector<el> tmp(++mid, data.end());
        sort(tmp.begin(), tmp.end(), cmp2);
        for(int i = 0; i < ans - 1; ++i) {
            ansInd.push_back(tmp[i].ind);
        }
    }

    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }

    long long l = 0;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l < r) {
        long long m = (l + r + 1)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        vector<el> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= m) {
                tmp.push_back(data[i]);
            }
        }
        sort(tmp.begin(), tmp.end(), cmp2);
        if (tmp.size() < m) {
            r = m - 1;
            continue;
        }
        long long tmpsum = 0;
            for(int i = 0; i < m; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok

                    ans = m;

                l = m;
            } else {
                r = m - 1;
            }

    }
    if (ans) {
        vector<el> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= ans) {
                tmp.push_back(data[i]);
            }
        }
        sort(tmp.begin(), tmp.end(), cmp2);

        for(int i = 0; i < ans; ++i) {
            ansInd.push_back(tmp[i].ind);
        }
    }
    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 0;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l <= r) {
        long long m = (l + r)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        vector<el> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= m) {
                tmp.push_back(data[i]);
            }
        }
        sort(tmp.begin(), tmp.end(), cmp2);
        if (tmp.size() < m) {
            r = m - 1;
            continue;
        }
        long long tmpsum = 0;
            for(int i = 0; i < m; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok
                if (m  > ans) {
                    //ok

                    ans = m;
                }
                l = m + 1;
            } else {
                r = m - 1;
            }

    }
    if (ans) {
        vector<long long> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= ans) {
                tmp.push_back(data[i].ind);
            }
        }
        sort(tmp.begin(), tmp.end());

        for(int i = 0; i < ans; ++i) {
            ansInd.push_back(tmp[i]);
        }
    }
    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 1;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l < r) {
        long long m = (l + r + 1)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        vector<el> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= m) {
                tmp.push_back(data[i]);
            }
        }
        sort(tmp.begin(), tmp.end(), cmp2);
        if (tmp.size() < m) {
            r = m - 1;
            continue;
        }
        long long tmpsum = 0;
            for(int i = 0; i < m; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok

                    ans = m;

                l = m;
            } else {
                r = m - 1;
            }

    }
    if (ans) {
        vector<long long> tmp;
        for(int i = 0; i < n; ++i) {
            if (data[i].a >= ans) {
                tmp.push_back(data[i].ind);
            }
        }
        sort(tmp.begin(), tmp.end());

        for(int i = 0; i < ans; ++i) {
            ansInd.push_back(tmp[i]);
        }
    }
    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


//
//  main.cpp
//  code1
//
//  Created by Irina Korneeva on 08/01/2018.
//  Copyright © 2018 Irina. All rights reserved.
//
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

#include <iostream>
using namespace std;
struct el {
    long long a, t, ind;
};

int cmp(el a, el b) {
    if (a.a == b.a) {
        return a.t < b.t;
    }
    return a.a < b.a;
}

int cmp2(el a, el b) {
    return a.t < b.t;
}
int cmpl(el a, long long x) {
    return a.a < x;
}

int main(int argc, const char * argv[]) {
    long long n, t;
    cin >> n >> t;
    vector<el> data;
    for (int i = 0; i < n; ++i) {
        el elem;
        cin >> elem.a >> elem.t;
        elem.ind = i + 1;
        data.push_back(elem);
    }
    sort(data.begin(), data.end(), cmp);
    long long l = 1;
    long long r = n;
    long long ans = 0;
    vector<long long> ansInd;
    while(l <= r) {
        long long m = (l + r)/2;
        //cout << l << ' ' << m << ' ' << r << '\n';
        auto mid = lower_bound(data.begin(), data.end(), m, cmpl);

        if (mid != data.end()) {
            m = mid->a;
            vector<el> tmp(++mid, data.end());
            sort(tmp.begin(), tmp.end(), cmp2);
            long long tmpsum = (--mid)->t;
            for(int i = 0; i < m - 1; ++i) {
                tmpsum += tmp[i].t;
                //cout << tmp[i].t << " ";
            }
            //cout << "lol\n";
            //cout << tmpsum << endl;
            if (tmpsum <= t) {
                //ok
                if (m > ans) {
                    //ok

                    ans = m;
                    ansInd.clear();
                    ansInd.push_back(mid->ind);
                    for(int i = 0; i < m - 1; ++i) {
                        ansInd.push_back(tmp[i].ind);
                    }
                }
                l = m + 1;
            } else {
                r = m - 1;
            }

        }

    }
    cout << ansInd.size() << "\n";
    cout << ansInd.size() << "\n";
    for (int i = 0; i < ansInd.size(); ++i) {
        cout << ansInd[i] << " ";

    }

    return 0;

}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

struct ob {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const ob& rhs) const {
    return this->t > rhs.t || (this->t == rhs.t && this->a < rhs.a) || (this->a == rhs.a && this->i < rhs.i);
  }
};

bool customord(const ob&a, const ob&b) {
  return a.a > b.a || (a.a==b.a && a.t < b.t);
}

set<ob> s;
ob o[200010];
map<i64,i64> co;

i64 score() {
  u64 k=s.size();
  u64 score=0;
  for(auto it=co.begin();it!=co.end();++it) {
    if(k > it->first) break;
    score += min(k-score,(u64)it->second);
  }
  return score;
}

int main(void) {
  i32 n;
  i64 T;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    o[i].i = i+1;
    cin >> o[i].a >> o[i].t;
  }

  sort(o,o+n,customord);

  u64 best=0;
  u64 sumt=0;
  string sol;

  for(i32 i=0;i<n;++i) {
    co[o[i].a]++;
    sumt += o[i].t;
    s.insert(o[i]);
    while(sumt > T) {
      auto it=s.begin();
      co[it->a]--;
      sumt -= it->t;
      s.erase(it);
    }
    if(s.size() > best) {
      u64 tmp=score();
      if(tmp > best) {
        best=tmp;
        sol = to_string(s.size())+"\n";
        for(auto it=s.begin();it!=s.end();++it) {
          sol += to_string(it->i)+" ";
        }
      }
    }
  }

  cout << best << endl;
  if(best > 0) cout << sol << endl;
  else cout << 0 << endl << endl;

  return 0;
}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

typedef struct ob {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const ob& rhs) const {
    return this->t > rhs.t || (this->t == rhs.t && this->a < rhs.a);
  }
}ob;

bool customord(const ob&a, const ob&b) {
  return a.a > b.a || (a.a==b.a && a.t < b.t);
}

set<ob> s;
ob o[200010];
map<i64,i64> co;

i64 score() {
  u64 k=s.size();
  u64 score=0;
  for(auto it=co.begin();it!=co.end();++it) {
    if(k > it->first) break;
    score += it->second;
  }
  return score;
}

int main(void) {
  i32 n;
  i64 T;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    o[i].i = i+1;
    cin >> o[i].a >> o[i].t;
  }

  sort(o,o+n,customord);

  u64 best=0;
  u64 sumt=0;
  string sol;

  for(i32 i=0;i<n;++i) {
    co[o[i].a]++;
    sumt += o[i].t;
    s.insert(o[i]);
    while(sumt > T) {
      auto it=s.begin();
      co[it->a]--;
      sumt -= it->t;
      s.erase(it);
    }
    u64 tmp=score();
    if(tmp > best) {
      best=tmp;
      sol = to_string(s.size())+"\n";
      for(auto it=s.begin();it!=s.end();++it) {
        sol += to_string(it->i)+" ";
      }
    }
  }

  cout << best << endl;
  if(best > 0) cout << sol << endl;
  else cout << 0 << endl << endl;

  return 0;
}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

typedef struct ob {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const ob& rhs) const {
    return this->t > rhs.t || (this->t == t && this->a > rhs.a);
  }
}ob;

bool customord(const ob&a, const ob&b) {
  return a.a < b.a || (a.a==b.a && a.t < b.t);
}

set<ob> s;
ob o[200010];
map<i64,i64> co;

i64 score() {
  u64 k=s.size();
  u64 score=0;
  for(auto it=co.rbegin();it!=co.rend();it++) {
    if(k <= it->first) {
      score += it->second;
    }
  }
  return score;
}

int main(void) {
  i32 n;
  i64 T;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    o[i].i = i+1;
    cin >> o[i].a >> o[i].t;
  }

  sort(o,o+n,customord);

  u64 best=0;
  u64 sumt=0;
  string sol;

  for(i32 i=0;i<n;++i) {
    co[o[i].a]++;
    sumt += o[i].t;
    s.insert(o[i]);
    while(sumt > T) {
      auto it=s.begin();
      co[it->a]--;
      sumt -= it->t;
      s.erase(it);
    }
    u64 tmp=score();
    if(tmp > best) {
      best=tmp;
      sol = to_string(s.size())+"\n";
      for(auto it=s.begin();it!=s.end();++it) {
        sol += to_string(it->i)+" ";
      }
    }
  }

  cout << best << endl;
  if(best > 0) cout << sol << endl;
  else cout << 0 << endl << endl;

  return 0;
}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

typedef struct ob {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const ob& rhs) const {
    return this->t > rhs.t || (this->t == t && this->a > rhs.a);
  }
}ob;

bool customord(const ob&a, const ob&b) {
  return a.a < b.a || (a.a==b.a && a.t < b.t);
}

set<ob> s;
ob o[200010];
map<i64,i64> co;

i64 score() {
  u64 k=s.size();
  u64 score=0;
  for(auto it=co.rbegin();it!=co.rend();it++) {
    if(k >= it->first) {
      score += it->second;
    }
  }
  return score;
}

int main(void) {
  i32 n;
  i64 T;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    o[i].i = i+1;
    cin >> o[i].a >> o[i].t;
  }

  sort(o,o+n,customord);

  u64 best=0;
  u64 sumt=0;
  string sol;

  for(i32 i=0;i<n;++i) {
    co[o[i].a]++;
    sumt += o[i].t;
    s.insert(o[i]);
    while(sumt > T) {
      auto it=s.begin();
      co[it->a]--;
      sumt -= it->t;
      s.erase(it);
    }
    u64 tmp=score();
    if(tmp > best) {
      best=tmp;
      sol = to_string(s.size())+"\n";
      for(auto it=s.begin();it!=s.end();++it) {
        sol += to_string((*it).i)+" ";
      }
    }
  }

  cout << best << endl;
  if(best > 0) cout << sol << endl;
  else cout << 0 << endl << endl;

  return 0;
}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

typedef struct ob {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const ob& rhs) const {
    return this->t > rhs.t || (this->t == rhs.t && this->a < rhs.a) || this->t < rhs.i;
  }
}ob;

bool customord(const ob&a, const ob&b) {
  return a.a > b.a || (a.a==b.a && a.t < b.t);
}

set<ob> s;
ob o[200010];
map<i64,i64> co;

i64 score() {
  u64 k=s.size();
  u64 score=0;
  for(auto it=co.begin();it!=co.end();++it) {
    if(k > it->first) break;
    score += min(k-score,(u64)it->second);
  }
  return score;
}

int main(void) {
  i32 n;
  i64 T;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    o[i].i = i+1;
    cin >> o[i].a >> o[i].t;
  }

  sort(o,o+n,customord);

  u64 best=0;
  u64 sumt=0;
  string sol;

  for(i32 i=0;i<n;++i) {
    co[o[i].a]++;
    sumt += o[i].t;
    s.insert(o[i]);
    while(sumt > T) {
      auto it=s.begin();
      co[it->a]--;
      sumt -= it->t;
      s.erase(it);
    }
    u64 tmp=score();
    if(tmp > best) {
      best=tmp;
      sol = to_string(s.size())+"\n";
      for(auto it=s.begin();it!=s.end();++it) {
        sol += to_string(it->i)+" ";
      }
    }
  }

  cout << best << endl;
  if(best > 0) cout << sol << endl;
  else cout << 0 << endl << endl;

  return 0;
}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

typedef struct ob {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const ob& rhs) const {
    return this->t > rhs.t || (this->t == t && this->a < rhs.a);
  }
}ob;

bool customord(const ob&a, const ob&b) {
  return a.a > b.a || (a.a==b.a && a.t < b.t);
}

set<ob> s;
ob o[200010];
map<i64,i64> co;

i64 score() {
  u64 k=s.size();
  u64 score=0;
  for(auto it=co.rbegin();it!=co.rend();it++) {
    if(k <= it->first) {
      score += it->second;
    }
  }
  return score;
}

int main(void) {
  i32 n;
  i64 T;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    o[i].i = i+1;
    cin >> o[i].a >> o[i].t;
  }

  sort(o,o+n,customord);

  u64 best=0;
  u64 sumt=0;
  string sol;

  for(i32 i=0;i<n;++i) {
    co[o[i].a]++;
    sumt += o[i].t;
    s.insert(o[i]);
    while(sumt > T) {
      auto it=s.begin();
      co[it->a]--;
      sumt -= it->t;
      s.erase(it);
    }
    u64 tmp=score();
    if(tmp > best) {
      best=tmp;
      sol = to_string(s.size())+"\n";
      for(auto it=s.begin();it!=s.end();++it) {
        sol += to_string(it->i)+" ";
      }
    }
  }

  cout << best << endl;
  if(best > 0) cout << sol << endl;
  else cout << 0 << endl << endl;

  return 0;
}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

struct Obj {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const Obj& O) const {
    return this->t < O.t || (this->t == O.t && this->a > O.a) || (this->a == O.a && this->i < O.i);
  }

  Obj(i32 a, i32 t, i32 i) : a(a), t(t), i(i) {}
};

set<Obj> s;
i32 fin[200010];
i64 T;

i32 score(i32 k) {
  i32 sc=0;
  i64 sumt=0;
  for(auto it=s.begin();it!=s.end() && sc < k;++it) {
    if(it->a < k) continue;
    sumt += it->t;
    fin[sc++] = it->i;
  }

  if(sumt > T) return -1;
  return sc;
}

int main(void) {
  i32 n;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    i32 a,t;
    cin >> a >> t;
    s.emplace(a,t,i+1);
  }

  i32 l=0;
  i32 r=n+1;

  while(r-l > 1) {
    i32 m=(l+r)/2;
    if(score(m) == m) {
      l=m;
    } else {
      r=m;
    }
  }

  score(l);

  cout << l << endl;
  cout << l << endl;
  for(i32 i=0;i<l;i++) cout << fin[i] << " ";
  cout << endl;

  return 0;
}


#include <iostream>      // Input/Output
#include <cstdio>        // C Input/Output

#include <algorithm>     // Useful functions such as sort, reverse, etc...
#include <cmath>         // Math functions

#include <bitset>        // Set of bits
#include <string>        // String type

#include <vector>        // Variable size array
#include <array>         // Fixed size array
#include <forward_list>  // Single-Linked lists
#include <list>          // Doubly-Linked lists

#include <set>           // Ordered set, tipically implemented as binary trees (value is the key)
#include <unordered_set> // Unordered set, faster for direct accesses
#include <map>           // Ordered maps, tipically binary trees (provides, map and multimap)
#include <unordered_map> // Unordered maps, faster for direct access, slower for iteration

#include <queue>         // FIFO queue, priority_queue
#include <deque>         // Double ended queue
#include <stack>         // LIFO stack

using i8  = char;
using u8  = unsigned char;
using i16 = short int;
using u16 = unsigned short int;
using i32 = long int;
using u32 = unsigned long int;
using i64 = long long int;
using u64 = unsigned long long int;

using f32 = float;
using f64 = double;
using f80 = long double;

using namespace std;

typedef struct ob {
  i32 a;
  i32 t;
  i32 i;

  bool operator<(const ob& rhs) const {
    return this->t > rhs.t || (this->t == t && this->a > rhs.a);
  }
}ob;

bool customord(const ob&a, const ob&b) {
  return a.t < b.t || (a.t==b.t && a.a < b.a);
}

set<ob> s;
ob o[200010];
map<i64,i64> co;

i64 score() {
  u64 k=s.size();
  u64 score=0;
  for(auto it=co.rbegin();it!=co.rend();it++) {
    if(k >= it->first) {
      score += it->second;
    }
  }
  return score;
}

int main(void) {
  i32 n;
  i64 T;

  cin >> n >> T;

  for(i32 i=0;i<n;++i) {
    o[i].i = i+1;
    cin >> o[i].a >> o[i].t;
  }

  sort(o,o+n,customord);

  u64 best=0;
  u64 sumt=0;
  string sol;

  for(i32 i=0;i<n;++i) {
    co[o[i].a]++;
    sumt += o[i].t;
    s.insert(o[i]);
    while(sumt > T) {
      auto it=s.begin();
      co[it->a]--;
      sumt -= it->t;
      s.erase(it);
    }
    u64 tmp=score();
    if(tmp > best) {
      best=tmp;
      sol = to_string(s.size())+"\n";
      for(auto it=s.begin();it!=s.end();++it) {
        sol += to_string((*it).i)+" ";
      }
    }
  }

  cout << best << endl;
  if(best > 0) cout << sol << endl;
  else cout << 0 << endl << endl;

  return 0;
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 10;
struct node{
	int a, t, i;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	if(a.t == b.t){
		return a.a > b.a;
	}
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T, big = 0;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			big++;
			tmp.insert(sa[i].i);
		}
		if(cnt == k) break;
	}
	if(cnt < k){
		for(int i = 0; i < n; i++){
			if(sa[i].a < k && time >= sa[i].t){
				cnt++;
				time -= sa[i].t;
				tmp.insert(sa[i].i);
			}
			if(cnt == k) break;
		}
	}
	if(cnt == k){
		return big;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
		sa[i].i = i;
	}
	sort(sa, sa+n, cmp);
	int l = 1, r = n, mid;
	int s = 0, k = 0;
	while(l <= r){
		mid = (l+r)/2;
		int x = check(mid);
		if(x){
			if(x > s){
				ans.clear();
				ans = tmp;
				s = x; k = mid;
			}
			l = mid+1;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 10;
struct node{
	int a, t, i;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	if(a.t == b.t){
		return a.a > b.a;
	}
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T, big = 0;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			big++;
			tmp.insert(sa[i].i);
		}
		if(cnt == k) break;
	}
	if(cnt < k){
		for(int i = 0; i < n; i++){
			if(sa[i].a < k && time >= sa[i].t){
				cnt++;
				time -= sa[i].t;
				tmp.insert(sa[i].i);
			}
			if(cnt == k) break;
		}
	}
	if(cnt == k){
		return big;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
		sa[i].i = i;
	}
	sort(sa, sa+n, cmp);
	int l = 0, r = n, mid;
	int s = 0, k = 0;
	while(l < r){
		mid = (l+r+1)/2;
		int x = check(mid);
		if(x){
			if(x > s){
				ans.clear();
				ans = tmp;
				s = x; k = mid;
			}
			l = mid;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;
struct node{
	int a, t, i;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	if(a.t == b.t){
		return a.a > b.a;
	}
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T, big = 0;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			big++;
			tmp.insert(sa[i].i);
		}
		if(cnt == k) break;
	}
	if(cnt < k){
		for(int i = 0; i < n; i++){
			if(sa[i].a < k && time >= sa[i].t){
				cnt++;
				time -= sa[i].t;
				tmp.insert(sa[i].i);
			}
			if(cnt == k) break;
		}
	}
	if(cnt == k){
		return big;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
		sa[i].i = i;
	}
	sort(sa, sa+n, cmp);
	int l = 1, r = n, mid;
	int s = 0, k = 0;
	while(l <= r){
		mid = (l+r)/2;
		int x = check(mid);
		if(x){
			if(x > s){
				ans.clear();
				ans = tmp;
				s = x; k = mid;
			}
			l = mid+1;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;
struct node{
	int a, t;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	if(a.t == b.t){
		return a.a > b.a;
	}
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T, big = 0;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			big++;
			tmp.insert(i);
		}
		if(cnt == k) break;
	}
	if(cnt < k){
		for(int i = 0; i < n; i++){
			if(sa[i].a < k && time >= sa[i].t){
				cnt++;
				time -= sa[i].t;
				tmp.insert(i);
			}
			if(cnt == k) break;
		}
	}
	if(cnt == k){
		return big;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
	}
	sort(sa, sa+n, cmp);
	int l = 1, r = n, mid;
	int s = 0, k = 0;
	while(l <= r){
		mid = (l+r)/2;
		int x = check(mid);
		if(x){
			if(x > s){
				ans.clear();
				ans = tmp;
				s = x; k = mid;
			}
			l = mid+1;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

int main(){
	int n, T;
	scanf("%d%d", &n, &T);
	vector<int> a(n), t(n);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &a[i], &t[i]);
	}
	vector<int> res;
	int l = 0, r = n;
	while(l <= r){
		int mid = (l+r+1) >> 1;
		vector<pair<int, int> > e;
		for(int i = 0; i < n; i++){
			if(a[i] >= mid){
				e.emplace_back(t[i], i);
			}
		}
		sort(e.begin(), e.end());
		bool ok = false;
		if((int)e.size() >= mid){
			int sum = 0;
			for(int i = 0; i < mid; i++){
				sum += e[i].first;
			}
			if(sum <= T){
				ok = true;
				res.resize(mid);
				for(int i = 0; i < mid; i++){
					res[i] = e[i].second;
				}
			}
		}
		if(ok){
			l = mid+1;
		}
		else{
			r = mid-1;
		}
	}
	int sz = (int) res.size();
	printf("%d\n%d\n", sz, sz);
	for(int i = 0; i < sz; i++){
		printf("%d ", res[i]+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 10;
struct node{
	int a, t, i;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T, big = 0;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			big++;
			tmp.insert(sa[i].i);
		}
		if(cnt == k) break;
	}
	if(cnt < k){
		for(int i = 0; i < n; i++){
			if(sa[i].a < k && time >= sa[i].t){
				cnt++;
				time -= sa[i].t;
				tmp.insert(sa[i].i);
			}
			if(cnt == k) break;
		}
	}
	if(cnt == k){
		return big;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
		sa[i].i = i;
	}
	sort(sa, sa+n, cmp);
	int l = 0, r = n, mid;
	int s = 0, k = 0;
	while(l < r){
		mid = (l+r+1)/2;
		int x = check(mid);
		if(x){
			if(x > s){
				ans.clear();
				ans = tmp;
				s = x; k = mid;
			}
			l = mid;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 2e5 + 10;
struct node{
	int a, t, i;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			tmp.insert(sa[i].i);
		}
		if(cnt == k) break;
	}
	if(cnt == k){
		return 1;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
		sa[i].i = i;
	}
	sort(sa, sa+n, cmp);
	int l = 0, r = n, mid;
	int s = 0, k = 0;
	while(l <= r){
		mid = (l+r+1)/2;
		if(check(mid)){
			if(mid > s){
				ans.clear();
				ans = tmp;
				s = mid; k = mid;
			}
			l = mid+1;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;
struct node{
	int a, t;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	if(a.t == b.t){
		return a.a > b.a;
	}
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T, big = 0;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			big++;
			tmp.insert(i);
		}
		if(cnt == k) break;
	}
	if(cnt < k){
		for(int i = 0; i < n; i++){
			if(sa[i].a < k && time >= sa[i].t){
				cnt++;
				time -= sa[i].t;
				tmp.insert(i);
			}
			if(cnt == k) break;
		}
	}
	if(cnt == k){
		return big;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
	}
	sort(sa, sa+n, cmp);
	int l = 0, r = n, mid;
	int s = 0, k = 0;
	while(l <= r){
		mid = (l+r)/2;
		int x = check(mid);
		if(x){
			if(x > s){
				ans.clear();
				ans = tmp;
				s = x; k = mid;
			}
			l = mid+1;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


#include <bits/stdc++.h>
using namespace std;

const int maxn = 1e5 + 10;
struct node{
	int a, t;
}sa[maxn];
int n, T;
set<int> ans, tmp;

int cmp(node a, node b){
	if(a.t == b.t){
		return a.a > b.a;
	}
	return a.t < b.t;
}

int check(int k){
	tmp.clear();
	int cnt = 0, time = T, big = 0;
	for(int i = 0; i < n; i++){
		if(sa[i].a >= k && time >= sa[i].t){
			cnt++;
			time -= sa[i].t;
			big++;
			tmp.insert(i);
		}
		if(cnt == k) break;
	}
	if(cnt < k){
		for(int i = 0; i < n; i++){
			if(sa[i].a < k && time >= sa[i].t){
				cnt++;
				time -= sa[i].t;
				tmp.insert(i);
			}
			if(cnt == k) break;
		}
	}
	if(cnt == k){
		return big;
	}
	else{
		return 0;
	}
}

int main(){
	scanf("%d%d", &n, &T);
	for(int i = 0; i < n; i++){
		scanf("%d%d", &sa[i].a, &sa[i].t);
	}
	sort(sa, sa+n, cmp);
	int l = 0, r = n, mid;
	int s = 0, k;
	while(l <= r){
		mid = (l+r)/2;
		int x = check(mid);
		if(x){
			if(x > s){
				ans.clear();
				ans = tmp;
				s = x; k = mid;
			}
			l = mid+1;
		}
		else{
			r = mid-1;
		}
	}
	printf("%d\n%d\n", s, k);
	for(set<int> :: iterator it = ans.begin(); it != ans.end(); it++){
		printf("%d ", (*it)+1);
	}
}


//Too Easy Problems
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define fill(a,v) memset(a,v,sizeof a)

pair <ll,ll> arr[2*123456];
ll N,T;
map <ll,ll> map1;

bool check(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	return count>=num;
}
void print(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	cout<<count<<endl;
	temp=T;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			cout<<arr[i].second+1<<" ";
			temp-=arr[i].first;
		}
	}
}

int main()
{
	ll i, j;
	cin>>N>>T;
	for(i=0;i<N;i++)
	{
		ll X,Y;
		cin>>X>>Y;
		arr[i]={Y,i};
		map1[i]=X;
	}
	sort(arr,arr+N);
	ll ans=0;
	ll L=0,R=N;
	while(L<=R)
	{
		ll mid=(L+R)/2;
		if(check(mid))
		{
			ans=mid;
			L=mid+1;
		}
		else
			R=mid-1;
	}
	cout<<ans<<endl;
	print(ans);
	return 0;
}


//Too Easy Problems
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define fill(a,v) memset(a,v,sizeof a)

pair <ll,ll> arr[2*123456];
ll N,T;
map <ll,ll> map1;

bool check(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	return count>=num;
}
void print(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	cout<<count<<endl;
	temp=T;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0)
		{
			cout<<arr[i].second+1<<" ";
			temp-=arr[i].first;
		}
	}
}

int main()
{
	ll i, j;
	cin>>N>>T;
	for(i=0;i<N;i++)
	{
		ll X,Y;
		cin>>X>>Y;
		arr[i]={Y,i};
		map1[i]=X;
	}
	sort(arr,arr+N);
	ll ans=0;
	ll L=0,R=N;
	while(L<=R)
	{
		ll mid=(L+R)/2;
		if(check(mid))
		{
			ans=mid;
			L=mid+1;
		}
		else
			R=mid-1;
	}
	cout<<ans<<endl;
	print(ans);
	return 0;
}


//Too Easy Problems
#include <bits/stdc++.h>
using namespace std;

#define ll int
#define mod 1000000007
#define fill(a,v) memset(a,v,sizeof a)

pair <ll,ll> arr[2*123456];
ll N,T;
map <ll,ll> map1;

bool check(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	return count>=num;
}
void print(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}

	printf("%d\n",count);
//	cout<<count<<endl;
	temp=T;
	count=0;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			printf("%d ",arr[i].second+1);
			//cout<<arr[i].second+1<<" ";
			temp-=arr[i].first;
		}
	}
}

int main()
{
	ll i, j;
	//cin>>N>>T;
	scanf("%d%d",&N,&T);
	for(i=0;i<N;i++)
	{
		ll X,Y;
		//cin>>X>>Y;
		scanf("%d%d",&X,&Y);
		arr[i]={Y,i};
		map1[i]=X;
	}
	sort(arr,arr+N);
	ll ans=0;
	ll L=0,R=N;
	while(L<=R)
	{
		ll mid=(L+R)/2;
		if(check(mid))
		{
			ans=mid;
			L=mid+1;
		}
		else
			R=mid-1;
	}
	printf("%d\n",ans);
//	cout<<ans<<endl;
	print(ans);
	return 0;
}


//Too Easy Problems
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define fill(a,v) memset(a,v,sizeof a)

pair <ll,ll> arr[2*123456];
ll N,T;
map <ll,ll> map1;

bool check(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	return count>=num;
}
void print(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	cout<<count<<endl;
	temp=T;
	count=0;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0 && count<num)
		{
			count++;
			cout<<arr[i].second+1<<" ";
			temp-=arr[i].first;
		}
	}
}

int main()
{
	ll i, j;
	cin>>N>>T;
	for(i=0;i<N;i++)
	{
		ll X,Y;
		cin>>X>>Y;
		arr[i]={Y,i};
		map1[i]=X;
	}
	sort(arr,arr+N);
	ll ans=0;
	ll L=0,R=N;
	while(L<=R)
	{
		ll mid=(L+R)/2;
		if(check(mid))
		{
			ans=mid;
			L=mid+1;
		}
		else
			R=mid-1;
	}
	cout<<ans<<endl;
	print(ans);
	return 0;
}


//Too Easy Problems
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define fill(a,v) memset(a,v,sizeof a)

pair <ll,ll> arr[2*123456];
ll N,T;
map <ll,ll> map1;

bool check(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	return count>=num;
}
void print(ll num)
{
	ll temp=T;
	ll count=0;
	ll i,j;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0)
		{
			count++;
			temp-=arr[i].first;
		}
	}
	cout<<count<<endl;
	temp=T;
	for(i=0;i<N;i++)
	{
		if(map1[arr[i].second]>=num && temp-arr[i].first>=0)
		{
			cout<<arr[i].second+1<<" ";
			temp-=arr[i].first;
		}
	}
}

int main()
{
	ll i, j;
	cin>>N>>T;
	for(i=0;i<N;i++)
	{
		ll X,Y;
		cin>>X>>Y;
		arr[i]={Y,i};
		map1[i]=X;
	}
	sort(arr,arr+N);
	ll ans=0;
	ll L=0,R=N;
	while(L<=R)
	{
		ll mid=(L+R)/2;
		if(check(mid))
		{
			ans=mid;
			L=mid+1;
		}
		else
			R=mid-1;
	}
	cout<<ans<<endl;
	print(ans);
	return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define in insert
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int inf = int (1e9) + 7;
const double eps = int (1e-9);
ll a[int (2e5 + 10)], t[int (2e5 + 10)], n, T;
vector <pair <int, int> > vec;
vector <int> res;

inline bool check (int v) {
	ll Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				++cnt;
	}
	return cnt >= v;
}

inline void go (int v) {
	ll Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				res.pb (i.s);
	}
}

int main () {
//  freopen ("in", "r", stdin);
//  freopen ("out", "w", stdout);

	cin >> n >> T;

	for (int i=1; i<=n; ++i)
		cin >> a[i] >> t[i],
			vec.pb ({t[i], i});

	sort (all (vec));

	ll l = 0, r = n;
	while (r - l > 1) {
		ll m = (r + l) / 2;
		if (check (m))
			l = m;
		else
			r = m;
	}
	if (check (r)) {
		cout << r << endl;
		go (r);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}
	else {
		cout << l << endl;
		go (l);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}

  return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define in insert
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int inf = int (1e9) + 7;
const double eps = int (1e-9);
int a[int (2e5 + 10)], t[int (2e5 + 10)], n, T;
vector <pair <int, int> > vec;
vector <int> res;

inline bool check (int v) {
	int Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				++cnt;
	}
	return cnt >= v;
}

inline void go (int v) {
	int Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				res.pb (i.s);
	}
}

int main () {

	cin >> n >> T;

	for (int i=1; i<=n; ++i)
		cin >> a[i] >> t[i],
			vec.pb ({t[i], i});

	sort (all (vec));

	int l = 0, r = n;
	while (r - l > 1) {
		int m = (r + l) / 2;
		if (check (m))
			l = m;
		else
			r = m - 1;
	}
	if (check (r)) {
		cout << r << endl;
		go (r);
		cout << r << endl;
		for (int i=0; i<r; ++i)
			cout << res[i] << " ";
	}
	else {
		cout << l << endl;
		go (l);
		cout << l << endl;
		for (int i=0; i<l; ++i)
			cout << res[i] << " ";
	}

  return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define in insert
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int inf = int (1e9) + 7;
const double eps = int (1e-9);
ll a[int (2e5 + 10)], t[int (2e5 + 10)], n, T;
vector <pair <int, int> > vec;
vector <int> res;

inline bool check (int v) {
	ll Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				++cnt;
	}
	return cnt >= v;
}

inline void go (int v) {
	ll Time = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				res.pb (i.s);
	}
}

int main () {
//  freopen ("in", "r", stdin);
//  freopen ("out", "w", stdout);

	cin >> n >> T;

	for (int i=1; i<=n; ++i)
		cin >> a[i] >> t[i],
			vec.pb ({t[i], i});

	sort (all (vec));

	ll l = 0, r = n;
	while (r - l > 1) {
		ll m = (r + l) / 2;
		if (check (m))
			l = m;
		else
			r = m;
	}
 	cout << l << endl;
 	go (l);
 	cout << sz(res) << endl;
 	for (auto i : res)
 		cout << i << " ";

  return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define in insert
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int inf = int (1e9) + 7;
const double eps = int (1e-9);
int a[int (2e5 + 10)], t[int (2e5 + 10)], n, T;
vector <pair <int, int> > vec;
vector <int> res;

inline bool check (int v) {
	int Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				++cnt;
	}
	return cnt >= v;
}

inline void go (int v) {
	int Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				res.pb (i.s);
	}
}

int main () {
//  freopen ("in", "r", stdin);
//  freopen ("out", "w", stdout);

	cin >> n >> T;

	for (int i=1; i<=n; ++i)
		cin >> a[i] >> t[i],
			vec.pb ({t[i], i});

	sort (all (vec));

	int l = 0, r = n;
	while (r - l > 1) {
		int m = (r + l) / 2;
		if (check (m))
			l = m;
		else
			r = m - 1;
	}
	if (check (r)) {
		cout << r << endl;
		go (r);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}
	else {
		cout << l << endl;
		go (l);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}

  return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define in insert
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int inf = int (1e9) + 7;
const double eps = int (1e-9);
ll a[int (2e5 + 10)], t[int (2e5 + 10)], n, T;
vector <pair <int, int> > vec;
vector <int> res;

inline bool check (int v) {
	ll Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				++cnt;
	}
	return cnt >= v;
}

inline void go (int v) {
	ll Time = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				res.pb (i.s);
	}
}

int main () {
//  freopen ("in", "r", stdin);
//  freopen ("out", "w", stdout);

	cin >> n >> T;

	for (int i=1; i<=n; ++i)
		cin >> a[i] >> t[i],
			vec.pb ({t[i], i});

	sort (all (vec));

	ll l = 0, r = n + 1;
	while (r - l > 1) {
		ll m = (r + l) / 2;
		if (check (m))
			l = m;
		else
			r = m;
	}
 	cout << l << endl;
 	go (l);
 	cout << sz(res) << endl;
 	for (auto i : res)
 		cout << i << " ";

  return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define in insert
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int inf = int (1e9) + 7;
const double eps = int (1e-9);
ll a[int (2e5 + 10)], t[int (2e5 + 10)], n, T;
vector <pair <int, int> > vec;
vector <int> res;

inline bool check (int v) {
	ll Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				++cnt;
	}
	return cnt >= v;
}

inline void go (int v) {
	ll Time = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				res.pb (i.s);
	}
}

int main () {
//  freopen ("in", "r", stdin);
//  freopen ("out", "w", stdout);

	cin >> n >> T;

	for (int i=1; i<=n; ++i)
		cin >> a[i] >> t[i],
			vec.pb ({t[i], i});

	sort (all (vec));

	ll l = 0, r = n;
	while (r - l > 1) {
		ll m = (r + l) / 2;
		if (check (m))
			l = m;
		else
			r = m;
	}
	if (check (l)) {
		cout << r << endl;
		go (r);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}
	else {
		cout << l << endl;
		go (l);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}

  return 0;
}


#include <bits/stdc++.h>

#define pb push_back
#define pf push_front
#define f first
#define s second
#define mp make_pair
#define in insert
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())

typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const int inf = int (1e9) + 7;
const double eps = int (1e-9);
ll a[int (2e5 + 10)], t[int (2e5 + 10)], n, T;
vector <pair <int, int> > vec;
vector <int> res;

inline bool check (int v) {
	ll Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				++cnt;
	}
	return cnt >= v;
}

inline void go (int v) {
	ll Time = 0, cnt = 0;
	for (auto i : vec) {
		if (a[i.s] >= v && Time + i.f <= T)
			Time += i.f,
				res.pb (i.s);
	}
}

int main () {
//  freopen ("in", "r", stdin);
//  freopen ("out", "w", stdout);

	cin >> n >> T;

	for (int i=1; i<=n; ++i)
		cin >> a[i] >> t[i],
			vec.pb ({t[i], i});

	sort (all (vec));

	ll l = 0, r = n;
	while (r - l > 1) {
		ll m = (r + l) / 2;
		if (check (m))
			l = m;
		else
			r = m - 1;
	}
	if (check (r)) {
		cout << r << endl;
		go (r);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}
	else {
		cout << l << endl;
		go (l);
		cout << sz(res) << endl;
		for (auto i : res)
			cout << i << " ";
	}

  return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n-1);

    int a, b;
    cin >> a >> b;
    T -= b;
    if (T == 0) {
        cout << 1 << endl << 1 << endl << 1;
        return 0;
    }
    if (T < 0) {
        cout << 0 << endl << 0;
        return 0;
    }
    int h = n;

    for (int i = 0; i < n-1; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 2;
    }
    int l = 1;
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n-1; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad && a == n) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j;
        if (a >= mid)
            j = 1;
        else
            j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    cout << l << endl;

    if (a >= l)
        cout << l << endl;
    else
        cout << l+1 << endl;
    cout << 1 << ' ';
    int mid = (l + h) / 2;
        t = 0;
        int j;
        if (a >= mid)
            j = 1;
        else
            j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                cout << pr[i].i << ' ';
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n-1);

    int a, b;
    cin >> a >> b;
    T -= b;
    if (T == 0) {
        cout << 1 << endl << 1 << endl << 1;
        return 0;
    }
    if (T < 0) {
        cout << 0 << endl << 0;
        return 0;
    }
    int h = n;

    for (int i = 0; i < n-1; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 2;
    }
    int l = 1;
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n-1; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad && a == n) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j = 1;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid && a >= mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    if (a >= l)
        cout << l << endl;
    else
        cout << l-1 << endl;

    cout << l << endl;
    cout << 1 << ' ';
    int mid = l;
    t = 0;
    int j = 1;
    for (int i = 0 ; i < n-1; i++) {
        if (pr[i].second < mid)
            continue;

        if ((pr[i].first + t) <= T) {
            t += pr[i].first;
            j++;
            cout << pr[i].i << ' ';
        } else
            break;
        if (j == mid)
            break;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pair <int, int> > pr(n-1);

    int a, b;
    cin >> a >> b;
    T -= b;
    if (T == 0 && a == 1) {
        cout << 1 << endl << 1 << endl << 1;
        return 0;
    }
    if (T < 0) {
        cout << 0 << endl << 0;
        return 0;
    }
    int h = n;

    for (int i = 0; i < n-1; i++) {
        cin >> pr[i].second >> pr[i].first;
    }
    int l = 1;
    sort(pr.begin(), pr.end());

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n-1; i++) {
        if ((pr[i].first + t) <= T && pr[i].second >= n-1) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad) {
        int s = a;
        for (int i = 0; i < n-1; i++)
            s = min(pr[i].second, s);
        cout << s << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j = 1;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }
    }

    if (a >= l)
        cout << l << endl;
    else
        cout << l-1 << endl;

    cout << l << endl;
    cout << 1 << ' ';
    int mid = (l + h) / 2;
    t = 0;
    int j = 1;
    for (int i = 0 ; i < n-1; i++) {
        if (pr[i].second < mid)
            continue;

        if ((pr[i].first + t) <= T) {
            t += pr[i].first;
            j++;
            cout << i + 2 << ' ';
        } else
            break;
        if (j == mid)
            break;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n);

    for (int i = 0; i < n; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 1;
    }
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    if (pr[0].first > T) {
        cout << 0 << endl << 0;
        return 0;
    }
    int l = 1;
    int h = n;
    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    cout << l << endl;
    cout << l << endl;

    int mid = (l + h) / 2;
        t = 0;
        int j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                cout << pr[i].i << ' ';
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n-1);

    int a, b;
    cin >> a >> b;
    T -= b;
    if (T == 0) {
        cout << 1 << endl << 1 << endl << 1;
        return 0;
    }
    if (T < 0) {
        cout << 0 << endl << 0;
        return 0;
    }
    int h = n;

    for (int i = 0; i < n-1; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 2;
    }
    int l = 1;
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n-1; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad && a == n) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j;
        if (a >= mid)
            j = 1;
        else
            j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    if (a >= l)
        cout << l << endl;
    else
        cout << l-1 << endl;

    cout << l << endl;
    cout << 1 << ' ';
    int mid = l;
    t = 0;
    int j = 1;
    for (int i = 0 ; i < n-1; i++) {
        if (pr[i].second < mid)
            continue;

        if ((pr[i].first + t) <= T) {
            t += pr[i].first;
            j++;
            cout << pr[i].i << ' ';
        } else
            break;
        if (j == mid)
            break;
    }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n-1);

    int a, b;
    cin >> a >> b;
    T -= b;
    if (T == 0) {
        cout << 1 << endl << 1 << endl << 1;
        return 0;
    }
    if (T < 0) {
        cout << 0 << endl << 0;
        return 0;
    }
    int h = n;

    for (int i = 0; i < n-1; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 2;
    }
    int l = 1;
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n-1; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad && a == n) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j;
        if (a >= mid)
            j = 1;
        else
            j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    cout << l << endl;

    if (a >= l)
        cout << l << endl;
    else
        cout << l+1 << endl;
    cout << 1 << ' ';
    int mid = (l + h) / 2;
        t = 0;
        int j;
        if (a >= mid)
            j = 1;
        else
            j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n);

    for (int i = 0; i < n; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 1;
    }
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    if (pr[0].first > T) {
        cout << 0 << endl << 0;
        return 0;
    }
    int l = 1;
    int h = n;
    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j = 0;
        for (int i = 0 ; i < n; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    cout << l << endl;
    cout << l << endl;

    int mid = (l + h) / 2;
        t = 0;
        int j = 0;
        for (int i = 0 ; i < n; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                cout << pr[i].i << ' ';
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n);

    for (int i = 0; i < n; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 1;
    }
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    if (pr[0].first > T) {
        cout << 0 << endl << 0;
        return 0;
    }
    int l = 1;
    int h = n;
    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j = 0;
        for (int i = 0 ; i < n; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    cout << l << endl;
    cout << l << endl;

    int mid = (l + h) / 2;
        t = 0;
        int j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                cout << pr[i].i << ' ';
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n);

    for (int i = 0; i < n; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 1;
    }
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    if (pr[0].first > T) {
        cout << 0 << endl << 0;
    }
    int l = 1;
    int h = n;
    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j == mid)
            l = mid;
        else
            h = mid;
        /*if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }*/
    }

    cout << l << endl;
    cout << l << endl;

    int mid = (l + h) / 2;
        t = 0;
        int j = 0;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                cout << pr[i].i << ' ';
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

struct pra {
    int first;
    int second;
    int i;
};

bool cmp(pra p1, pra p2) {
    return p1.first < p2.first;
}

int main(void)
{
    //freopen("input.txt", "r", stdin);

    cin.sync_with_stdio(0);
    cin.tie(NULL);
    cout << fixed << setprecision(25);

    int n, T;
    cin >> n >> T;
    vector <pra> pr(n-1);

    int a, b;
    cin >> a >> b;
    T -= b;
    if (T == 0) {
        cout << 1 << endl << 1 << endl << 1;
        return 0;
    }
    if (T < 0) {
        cout << 0 << endl << 0;
        return 0;
    }
    int h = n;

    for (int i = 0; i < n-1; i++) {
        cin >> pr[i].second >> pr[i].first;
        pr[i].i = i + 2;
    }
    int l = 1;
    sort(pr.begin(), pr.end(), cmp);

    int t = 0;
    bool bad = false;
    for (int i = 0 ; i < n-1; i++) {
        if ((pr[i].first + t) <= T && pr[i].second == n) {
            t += pr[i].first;
        }
        else {
            bad = true;
            break;
        }
    }
    if (!bad && a == n) {
        cout << n << endl << n << endl;
        for (int i = 0; i < n; i++)
            cout << i + 1<< ' ';
        return 0;
    }

    while (h - l > 1) {
        int mid = (l + h) / 2;
        int t = 0;
        int j = 1;
        for (int i = 0 ; i < n-1; i++) {
            if (pr[i].second < mid)
                continue;

            if ((pr[i].first + t) <= T) {
                t += pr[i].first;
                j++;
            } else
                break;
            if (j == mid)
                break;
        }
        if (j < mid) {
            h = mid;
        } else {
            l = mid;
        }
    }

    if (a >= l)
        cout << l << endl;
    else
        cout << l-1 << endl;

    cout << l << endl;
    cout << 1 << ' ';
    int mid = (l + h) / 2;
    t = 0;
    int j = 1;
    for (int i = 0 ; i < n-1; i++) {
        if (pr[i].second < mid)
            continue;

        if ((pr[i].first + t) <= T) {
            t += pr[i].first;
            j++;
            cout << pr[i].i << ' ';
        } else
            break;
        if (j == mid)
            break;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

priority_queue<P, vector<P>, greater<P> >pque;
priority_queue<P, vector<P>, greater<P> >best;

int n,T;
int a[200050],t[200050];
P at[200050];

int main() {
    int a,b;
    cin >> n >> T;
    for(int i = 0; i < n; i++){
        scanf("%d%d", &a, &b);
        at[i].first = a, at[i].second = b;
    }
    sort(at, at+n, greater<P>());
//    for(int i = 0; i < n; i++){
//        cout << at[i].first << " " << at[i].second << endl;
//    }
    int res = 0;
    int pos = 0;
    int now = at[0].first;
    int sum = 0;
    while(true){
        if(pos >= n) break;
        if(sum + at[pos].second > T || now < pque.size()+1) break;
        pque.push(P(at[pos].second, pos));
        sum += at[pos].second;
        now = at[pos].first;
        pos++;
    }
    res = pque.size();
    best = pque;
    while(true){
        //cout << pos << endl;
        if(pos >= n) break;
        int rem = pque.size()+1-now;
        if(at[pos].second > T){
            pos++;
            continue;
        }
        pque.push(P(at[pos].second, pos));
        sum += at[pos].second;
        now = at[pos].first;
        //cout << "sum =  :" << sum << " rem : " << rem << endl;
        while((rem-- >0 || sum > T) && !pque.empty()){

            sum -= pque.top().first;
            pque.pop();
        }
        //cout << pque.size() << endl;

        pos++;
        if(pque.size() > res){
            res = pque.size();
            best = pque;
        }
    }
    cout << res << endl;
    cout << best.size() << endl;
    while(best.size() > 0){
        cout << best.top().second + 1 << " ";
        best.pop();
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

int n, T;
int a[200050], t[200050];
vector<int> res;
vector<int> good;
bool check(int k){
    res.clear();
    vector<P> time;
    for(int i = 0; i < n; i++){
        if(a[i] >= k) time.push_back(P(t[i],i));
    }
    if(time.size() < k) return false;
    sort(time.begin(), time.end());
    int sum = 0;
    for(int i = 0; i < k; i++) sum += time[i].first, res.push_back(time[i].second);
    if(sum <= T){
        good = res;
        return true;
    }
    return false;
}

int main(){
    scanf("%d%d", &n, &T);
    for(int i = 0; i < n; i++) scanf("%d%d", &a[i], &t[i]);
    int l = -1, r = n+1, mid = (l+r) /2;
    while(l+1 < r){
        if(check(mid)){
            l = mid;
        }
        else{
            r = mid;
        }
        mid = (r + l) / 2;
        //cout << l << " " << mid << " " << r << endl;
    }
    cout << good.size() << endl;
    cout << good.size() << endl;
    for(int i = 0; i < good.size(); i++) printf("%d ", good[i]+1);

}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

priority_queue<P, vector<P>, greater<P> >pque;
priority_queue<P, vector<P>, greater<P> >best;

int n,T;
int a[200050],t[200050];
P at[200050];

int main() {
    int a,b;
    cin >> n >> T;
    for(int i = 0; i < n; i++){
        scanf("%d%d", &a, &b);
        at[i].first = a, at[i].second = b;
    }
    sort(at, at+n, greater<P>());
//    for(int i = 0; i < n; i++){
//        cout << at[i].first << " " << at[i].second << endl;
//    }
    int res = 0;
    int pos = 0;
    int now = at[0].first;
    int sum = 0;
//    while(true){
//        if(pos >= n) break;
//        if(sum + at[pos].second > T || now < pque.size()+1) break;
//        pque.push(P(at[pos].second, pos));
//        sum += at[pos].second;
//        now = at[pos].first;
//        pos++;
//    }
    res = pque.size();
    best = pque;
    while(true){
        //cout << pos << endl;
        if(pos >= n) break;
        if(at[pos].second > T){
            pos++;
            continue;
        }
        pque.push(P(at[pos].second, pos));
        sum += at[pos].second;
        now = at[pos].first;
        //cout << "sum =  :" << sum << " rem : " << rem << endl;
        while((pque.size() > now || sum > T) && !pque.empty()){
            sum -= pque.top().first;
            pque.pop();
        }
        //cout << pque.size() << endl;

        pos++;
        if(pque.size() > res){
            res = pque.size();
            best = pque;
        }
    }
    cout << res << endl;
    cout << best.size() << endl;
    while(best.size() > 0){
        printf("%d ", best.top().second);
        best.pop();
    }
}


#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> P;

priority_queue<P, vector<P>, greater<P> >pque;
priority_queue<P, vector<P>, greater<P> >best;

int n,T;
int a[200050],t[200050];
P at[200050];

int main() {
    int a,b;
    cin >> n >> T;
    for(int i = 0; i < n; i++){
        scanf("%d%d", &a, &b);
        at[i].first = a, at[i].second = b;
    }
    sort(at, at+n, greater<P>());
//    for(int i = 0; i < n; i++){
//        cout << at[i].first << " " << at[i].second << endl;
//    }
    int res = 0;
    int pos = 0;
    int now = at[0].first;
    int sum = 0;
//    while(true){
//        if(pos >= n) break;
//        if(sum + at[pos].second > T || now < pque.size()+1) break;
//        pque.push(P(at[pos].second, pos));
//        sum += at[pos].second;
//        now = at[pos].first;
//        pos++;
//    }
    res = pque.size();
    best = pque;
    while(true){
        //cout << pos << endl;
        if(pos >= n) break;
        if(at[pos].second > T){
            pos++;
            continue;
        }
        pque.push(P(at[pos].second, pos));
        sum += at[pos].second;
        now = at[pos].first;
        //cout << "sum =  :" << sum << " rem : " << rem << endl;
        while((pque.size() > now || sum > T) && !pque.empty()){
            sum -= pque.top().first;
            pque.pop();
        }
        //cout << pque.size() << endl;

        pos++;
        if(pque.size() > res){
            res = pque.size();
            best = pque;
        }
    }
    cout << res << endl;
    cout << best.size() << endl;
    while(best.size() > 0){
        cout << best.top().second + 1 << " ";
        best.pop();
    }
}