You have N items that you want to put them into a knapsack. Item i has value vi and weight wi.

You want to find a subset of items to put such that:

* The total value of the items is as large as possible.
* The items have combined weight at most W, that is capacity of the knapsack.



Find the maximum total value of items in the knapsack.

Constraints

* 1 ≤ N ≤ 40
* 1 ≤ vi ≤ 1015
* 1 ≤ wi ≤ 1015
* 1 ≤ W ≤ 1015

Input


N W
v1 w1
v2 w2
:
vN wN


The first line consists of the integers N and W. In the following N lines, the value and weight of the i-th item are given.

Output

Print the maximum total values of the items in a line.

Examples

Input

4 5
4 2
5 2
2 1
8 3


Output

13


Input

2 20
5 9
4 10


Output

9
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,W;
    cin >> n >> W;
    vector<ll> v(n);
    vector<ll> w(n);
    for(i = 0;i < n;++i){
        cin >> v.at(i) >> w.at(i);
    }

    ll n2 = n/2;
    vector<pair<ll,ll>> tmp_sum1;
    for(ll bit = 0;bit < (1 << n2);++bit){
        ll w_sum = 0;
        ll v_sum = 0;
        for(i = 0;i < n2;++i){
            if(bit & (1 << i)){
                w_sum += w.at(i);
                v_sum += v.at(i);
            }
        }
        if(w_sum <= W) tmp_sum1.emplace_back(w_sum,-v_sum);
    }
    sort(all(tmp_sum1));
    vector<pair<ll,ll>> sum1;
    for(i = 0;i < tmp_sum1.size();++i){
        ll w_sum = tmp_sum1.at(i).first;
        ll v_sum = -tmp_sum1.at(i).second;
        if(i == 0){
            sum1.emplace_back(w_sum, v_sum);
        }else{
            if(sum1.back().second < v_sum) sum1.emplace_back(w_sum, v_sum);
        }
    }

    ll n22 = n - n2;
    vector<pair<ll,ll>> tmp_sum2;
    for(ll bit = 0;bit < (1 << n22);++bit){
        ll w_sum = 0;
        ll v_sum = 0;
        for(i = 0;i < n22;++i){
            if(bit & (1 << i)){
                w_sum += w.at(i + n2);
                v_sum += v.at(i + n2);
            }
        }
        if(w_sum <= W) tmp_sum2.emplace_back(w_sum,-v_sum);
    }
    sort(all(tmp_sum2));
    vector<pair<ll,ll>> sum2;
    for(i = 0;i < tmp_sum2.size();++i){
        ll w_sum = tmp_sum2.at(i).first;
        ll v_sum = -tmp_sum2.at(i).second;
        if(i == 0){
            sum2.emplace_back(w_sum, v_sum);
        }else{
            if(sum2.back().second < v_sum) sum2.emplace_back(w_sum, v_sum);
        }
    }

    ll ans = 0;
    for(i = 0;i < sum1.size();++i){
        ll w_sum = sum1.at(i).first;
        ll v_sum = sum1.at(i).second;
        auto itr = lower_bound(all(sum2), make_pair(W-w_sum+1, 0ll));
        if(itr != sum2.begin()) ans = max(ans, v_sum + (*--itr).second);
    }
    cout << ans << endl;
    return 0;
}
