#include using namespace std; #define rep(i,n) for(int i = 0; i < (n);i++) #define sz(x) int(x.size()) typedef long long ll; typedef pair P; int main(){ int n; ll k; cin >> n >> k; vector a(n), b(n); rep(i,n) cin >> a[i] >> b[i]; auto ok = [&](int x) { ll t = 0; rep(i,n) { if (x >= a[i]) t += min(b[i],x) - a[i] + 1; } return t >= k; }; int l = 0, r = 1e9; while (r - l > 1) { int mid = (l + r)/2; if (ok(mid)) r = mid; else l = mid; } cout << r << endl; return 0; }