#include using namespace std; #pragma GCC optimize("Ofast") #define rep(i,n) for(ll i=0;i=0;i--) #define perl(i,r,l) for(ll i=r-1;i>=l;i--) #define fi first #define se second #define pb push_back #define ins insert #define pqueue(x) priority_queue,greater> #define all(x) (x).begin(),(x).end() #define CST(x) cout<> #define rev(x) reverse(x); using ll=long long; using vl=vector; using vvl=vector>; using pl=pair; using vpl=vector; using vvpl=vector; const ll MOD=1000000007; const ll MOD9=998244353; const int inf=1e9+10; const ll INF=4e18; const ll dy[9]={0,1,-1,0,1,1,-1,-1,0}; const ll dx[9]={1,0,0,-1,1,-1,1,-1,0}; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } ll n,W; ll nowbest=0; vpl v; void dfs(ll depth,ll value,ll weight){ if(depth==n){ return; } if(W-weight>=v[depth].second){ value+=v[depth].first;chmax(nowbest,value); weight+=v[depth].second; double ld=0; ll ret=W-weight; for(ll k=depth+1;k=v[k].second){ ret-=v[k].second; ld+=v[k].first; } else{ ld+=double(v[k].first)*ret/v[k].second; break; } } if(ld+value>=double(nowbest)){ dfs(depth+1,value,weight); } value-=v[depth].first; weight-=v[depth].second; } double ld=0; ll ret=W-weight; for(ll k=depth+1;k=v[k].second){ ret-=v[k].second; ld+=v[k].first; } else{ ld+=double(v[k].first)*ret/v[k].second; break; } } if(ld+value>=double(nowbest)){ dfs(depth+1,value,weight); } } int main(){ cin >> n >> W; v.resize(n); rep(i,n){ ll a,b;cin >> a >> b; v[i]=make_pair(a,b); } sort(all(v),[](pl a,pl b){return double(a.first)/a.second>double(b.first)/b.second;}); dfs(0,0,0); cout << nowbest << endl; }