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>
using namespace std;
int N; long long W, v[55], w[55], pv[16777222], pw[16777222], lv[16777222], lw[16777222], rv[16777222], rw[16777222];
int main() {
	cin >> N >> W;
	for (int i = 0; i < N; i++) cin >> v[i] >> w[i];
	int lp = N / 2, rp = N - lp;
	for (int i = 0; i < lp; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			lv[j] = lv[j - (1 << i)] + v[i];
			lw[j] = lw[j - (1 << i)] + w[i];
		}
		int lc = 0, rc = 1 << i; long long nv = 0;
		for (int j = 0; j < 2 << i; j++) {
			long long lt = (lc != 1 << i ? lw[lc] : 1LL << 60);
			long long rt = (rc != 2 << i ? lw[rc] : 1LL << 60);
			if (lt < rt) nv = max(nv, lv[lc]), pv[j] = nv, pw[j] = lw[lc++];
			else nv = max(nv, lv[rc]), pv[j] = nv, pw[j] = lw[rc++];
		}
		for (int j = 0; j < 2 << i; j++) lv[j] = pv[j], lw[j] = pw[j];
	}
	for (int i = 0; i < rp; i++) {
		for (int j = 1 << i; j < 2 << i; j++) {
			rv[j] = rv[j - (1 << i)] + v[i + lp];
			rw[j] = rw[j - (1 << i)] + w[i + lp];
		}
		int lc = 0, rc = 1 << i; long long nv = 0;
		for (int j = 0; j < 2 << i; j++) {
			long long lt = (lc != 1 << i ? rw[lc] : 1LL << 60);
			long long rt = (rc != 2 << i ? rw[rc] : 1LL << 60);
			if (lt < rt) nv = max(nv, rv[lc]), pv[j] = nv, pw[j] = rw[lc++];
			else nv = max(nv, rv[rc]), pv[j] = nv, pw[j] = rw[rc++];
		}
		for (int j = 0; j < 2 << i; j++) rv[j] = pv[j], rw[j] = pw[j];
	}
	int pos = (1 << rp) - 1; long long ret = 0;
	for (int i = 0; i < 1 << lp; i++) {
		while (pos >= 0 && lw[i] + rw[pos] > W) pos--;
		if (pos != -1) ret = max(ret, lv[i] + rv[pos]);
	}
	cout << ret << endl;
	return 0;
}