boolgo(vector<P>& p){ sort(p.begin(), p.end(), [](const P& a, const P& b){ return a.v < b.v; }); static LL t[maxn]; memset(t, 0, sizeof t); LL cc = c, cnt = 1E18; for (int i = (int)p.size() - 1; i >= 0; --i) { t[i] = min(p[i].k, cc / p[i].v); cc -= t[i] * p[i].v; } for (int i = 0; i < (int)p.size(); ++i) if (cc > 0 && p[i].k - t[i] > 0) { cc -= p[i].v; ++t[i]; break; } if (cc > 0) returnfalse;
for (int i = 0; i < (int)p.size(); ++i) { if (t[i]) cnt = min(cnt, p[i].k / t[i]); } for (int i = 0; i < (int)p.size(); ++i) p[i].k -= cnt * t[i];
ans += cnt; returntrue; }
intmain(){ cin >> n >> c; for (int i = 0; i < n; ++i) cin >> v[i] >> k[i]; for (int i = 0; i < n; ++i) p.push_back({v[i], k[i]}); while (go(p)); cout << ans << endl; }