#include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <set>
#include <cstdio>
#include <vector>
#include <iostream>
#include <utility>
#include <queue>
#include <map>

#define fir first
#define sec second
#define sz(s) (s).size()
#define pb push_back
#define get(n) scanf("%d",&n);
#define gets(s) string s;cin >> (s);
#define prfi(n) printf("%d", &n);
#define prfd(n) printf("%lf", &n);
#define All(s) (s).begin(), (s).end()
#define rep(i,j) for(int (i)=0;(i)<(j);(i)++)
#define For(i,j,k) for(int (i)=(j);(i)<(k);(i)++)
#define repd(i,j) for(int (i)=(j);(i)>=0;(i)--)
#define Ford(i,j,k) for(int (i)=(j);i>=(k);i--)
#define vfor(c,v) for(auto (c): v)
#define dump(x)  std::cout << #x << " = " << (x) << std::endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using ll = long long;
using pii = std::pair<int,int>;
using pll = std::pair<ll, ll>;
using vi = std::vector<int> ;
using vvi = std::vector<vi> ;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vd = std::vector<double> ;
using vvd = std::vector<vd> ;
using qi = std::queue<int> ;
using vpii = std::vector<std::pair<int, int> >;
using vpll = std::vector<pll>;
using namespace std;

const int Mod = (1e9) + 7;
const int max_n = 3 * (1e5) + 1;
const int max_m = 83 * (1e5) + 1;
const int INF = 1e9 + 19;
const ll INFL = 1e18 + 19;
const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
//_____________________________________Templates_________________________________________//

template<class T1, class T2> inline void chmin(T1 &a, T2 b){if(a > b) a = b;}
template<class T1, class T2> inline void chmax(T1 &a, T2 b){if(a < b) a = b;}

//mainly use for dynamic prog
template<class T1, class T2>
void update(T1 &a, T2 b){
  a += b;
  if(a > Mod) a %= Mod;
}

inline void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

inline void OUT(void){
  cout << "\n";
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}
bool pairsort(pll pl, pll pr){
  if(pl.first == pr.first)return pl.second > pr.second;
  return pl.first < pr.first;
}
//_____________________　following sorce code_________________________//
int n,m,k;
//vvll dp(400, vll(400));
string S;
int a,b,c;
ll w;
vpll vp;
vpll up;
vll v;
vll cost;
vll u;
bool check(){
}

int LowerBound(ll x){
  int n2 = n/2;
  int l = 0, r = (1 << n2);
  while(l+1<r){
    int c = (l+r)/2;
    if(vp[c].first <= x)l = c;
    else r = c;
  }
  return l;
}

int main () {
  cin.tie(0);
  ios::sync_with_stdio(false);
  IN(n,w);
  //OUT(n,w);
  v = cost = vll(n);
  rep(i,n){
    IN(v[i], cost[i]);
  }
  //for(auto c : cost)OUT(c);
  int _n = n /2;
  vp = vpll(1 << _n);
  rep(i,1 << _n){
    ll sw = 0, sv = 0;
    rep(j,_n){
      if(i &(1<<j)){
        //dump(j);
        //dump(cost[j]);
        //dump(v[j]);
        sw += cost[j];
        sv += v[j];
      }
    }
    //dump(i);
    //dump(sw);
    //dump(sv);
    vp[i] = make_pair(sw, sv);
  }

  sort(All(vp),pairsort);
  pll p = vp[0];
  For(i,1,1 << _n){
    if(p.second > vp[i].second){
      vp[i] = p;
    }
    else {
      p = vp[i];
    }
  }
  /*for(auto c : vp){
  	OUT(c.fir, c.sec);
  }*/
  ll res = 0;
  rep(i,1 << (n - _n)){
    ll sw = 0, sv = 0;
    rep(j,n - _n){
      if(i & (1 << j)){
        sw += cost[_n+j];
        sv += v[_n+j];
      }
    }
    //dump(sw);
    //dump(sv);
    if(sw <= w){
      //dump(sw);
      ll pos = LowerBound(w - sw);
      //dump(pos);
      //OUT(sw+vp[pos].second);
      chmax(res, sv + vp[pos].second);
    }
  }
  /*for(auto c : vp){
  	OUT(c.fir, c.sec);
  }*/
  cout << res << endl;
  //cout << fixed << setprecision(15) << ans << endl;
  return 0;
}


Measured memory_bytes: 19172