#include <bits/stdc++.h>
long long n,w,p[10000000],v[10000000],d[10000000],tong=0,tl=0,t=0;
using namespace std;
void Try(long long i)
{
for (long long j=1;j<=n;j++)
{
if (d[j]==0)
if (tl+p[j]>w)
{
break;
}
else
{
d[j]=1;
tl+=p[j];
t+=v[j];
tong=max(tong,t);
Try(i+1);
d[j]=0;
tl-=p[j];
t-=v[j];
}
}
}
int main() {
freopen("balo.inp","r",stdin);
freopen("balo.out","w",stdout);
cin>>n>>w;
for (long long i=1;i<=n;++i)
cin>>p[i]>>v[i];
Try(1);
cout<<tong;
return 0;}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CmxvbmcgbG9uZyBuLHcscFsxMDAwMDAwMF0sdlsxMDAwMDAwMF0sZFsxMDAwMDAwMF0sdG9uZz0wLHRsPTAsdD0wOwp1c2luZyBuYW1lc3BhY2Ugc3RkOwp2b2lkIFRyeShsb25nIGxvbmcgaSkKewogICAgZm9yIChsb25nIGxvbmcgaj0xO2o8PW47aisrKQogICAgewogICAgICAgIGlmIChkW2pdPT0wKQogICAgICAgICAgICBpZiAodGwrcFtqXT53KQogICAgICAgIHsKICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGRbal09MTsKICAgICAgICAgICAgICAgIHRsKz1wW2pdOwogICAgICAgICAgICAgICAgdCs9dltqXTsKICAgICAgICAgICAgICAgIHRvbmc9bWF4KHRvbmcsdCk7CiAgICAgICAgICAgICAgICBUcnkoaSsxKTsKICAgICAgICAgICAgICAgIGRbal09MDsKICAgICAgICAgICAgICAgIHRsLT1wW2pdOwogICAgICAgICAgICAgICAgdC09dltqXTsKICAgICAgICAgICAgfQogICAgfQp9CmludCBtYWluKCkgewogICAgZnJlb3BlbigiYmFsby5pbnAiLCJyIixzdGRpbik7CiAgICBmcmVvcGVuKCJiYWxvLm91dCIsInciLHN0ZG91dCk7CiAgICBjaW4+Pm4+Pnc7CiAgICBmb3IgKGxvbmcgbG9uZyBpPTE7aTw9bjsrK2kpCiAgICAgICAgY2luPj5wW2ldPj52W2ldOwogICAgVHJ5KDEpOwogICAgY291dDw8dG9uZzsKICAgIHJldHVybiAwO30K