#include using namespace std; using LL = long long int; const int MAX_N = 50005; int N; class Gift{ public: LL V, W; double value; void input() { cin >> V >> W; value = (double)V/(double)W; } bool operator < (const Gift& p) const { return value < p.value; } bool operator > (const Gift& p) const { return value > p.value; } }G[MAX_N]; LL W; LL ans = 0; LL solve(int pos = 0, LL tmpV = 0, LL tmpW = 0) { if((double)ans > tmpV + (double)(W-tmpW)*G[pos].value) { return tmpV; } if(pos == N) { ans = max(ans, tmpV); return tmpV; } LL ret = 0; if(tmpW + G[pos].W <= W) { ret = max(ret, solve(pos+1, tmpV+G[pos].V, tmpW+G[pos].W)); } ret = max(ret, solve(pos+1, tmpV, tmpW)); ans = max(ret, ans); return ret; } int main() { cin >> N >> W; for(int i = 0; i < N; i++) { G[i].input(); } sort(G, G+N, greater()); solve(); cout << ans << endl; return 0; }