#include long long branch_and_bound(int n, long long c, const std::vector &v, const std::vector &w) { std::vector vv(n), ww(n); { std::vector id(n); std::iota(id.begin(), id.end(), 0); std::sort(id.begin(), id.end(), [&](int i, int j) { return 1.0 * v[i] * w[j] > 1.0 * v[j] * w[i]; }); for (int i = 0; i < n; ++i) { vv[i] = v[id[i]]; ww[i] = w[id[i]]; } } long long ans = 0; std::function dfs = [&](int x, long long sv, long long sw) { if (c < sw) return; if (x == n) return ans = std::max(ans, sv), void(); long long gsv = sv, gsw = sw; int y = x; for ( ; y < n && gsw + w[y] <= c; ++y) { gsv += vv[y]; gsw += ww[y]; } if (gsw == c || y == n) return ans = std::max(ans, gsv), void(); if (gsv + 1.0 * vv[y] * (c - gsw) / ww[y] <= ans) return; dfs(x + 1, sv + vv[x], sw + ww[x]); dfs(x + 1, sv, sw); }; dfs(0, 0, 0); return ans; } signed main() { std::ios::sync_with_stdio(false); int N; long long C; std::cin >> N >> C; std::vector V(N), W(N); for (int i = 0; i < N; ++i) { std::cin >> V[i] >> W[i]; } std::cout << branch_and_bound(N, C, V, W) << std::endl; return 0; }