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 <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
    ll N, W, i, j, k;
    cin >> N >> W;
    vector<ll> v(N), w(N);

    for(i = 0; i < N;i++){
        cin >> v[i] >> w[i];
    }
    vector<pair<ll, ll> > H1, H2;
    ll m = N / 2;
    for(i = 0; i < 1 << m;i++){
        ll Wcnt = 0, Vcnt = 0;
        for(j = 0; j < m; j++) {
            if(i >> j & 1){
                Wcnt += w[j];
                Vcnt += v[j];
            }
        }
        H1.push_back(make_pair(Wcnt, Vcnt));
    }
    ll r = N - m;
    for(i = 0; i < 1 << r;i++){
        ll Wcnt = 0, Vcnt = 0;
        for(j = 0; j < r; j++) {
            if(i >> j & 1) {
                Wcnt += w[j + m];
                Vcnt += v[j + m];
            }
        }
        H2.push_back(make_pair(Wcnt, Vcnt));
    }
    sort(H2.begin(), H2.end());
    //cout << H1[2].first << endl;
    //cout << H2[2].second << endl;
    ll ret = 0;
    ll H1s = H1.size();
    ll H2s = H2.size();
    for(i = 1; i < H2s;i++){
        H2[i].second = max(H2[i - 1].second, H2[i].second);
    }
    for(i = 0; i < H1s; i++) {
        if(W - H1[i].first >= 0) {
            auto it = lower_bound(H2.begin(), H2.end(), make_pair(W - H1[i].first, ll(1e16)));
            if(it != H2.begin()) {
                --it;
                //cout << it->first << endl;
                ret = max(ret, it->second + H1[i].second);
            }
        }
    }
    cout << ret << endl;
    return 0;
}
