#include using namespace std; struct pizza{ int p; int d; }; int main(){ int n, k; cin >> n >> k; vector v(n); for(int i = 0; i < n; i++){ cin >> v[i].p >> v[i].d; } sort(v.begin(), v.end(), [](pizza &l, pizza &r){ return l.p > r.p; }); assert(n < 30); int ans = 0; for(int i = 0; i < (1 << n); i++){ int deli = 0; int price = 0; int count = 0; for(int j = 0; j < n; j++){ if(i & (1 << j)){ count++; if(count & 1) price += v[j].p; deli += v[j].d; } } if(price <= k) ans = max(ans, deli); } cout << ans << endl; }