#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,a,b) for (int i = (a); i < (b); i++) #define case(i) cout<<"Case #"< com; const int mod = 1e9 + 7; const int MOD = 998244353; const ll INF = 4e18; int main() { int n, k; cin >> n >> k; vector> a(n); rep(i, 0, n) cin >> a[i].first >> a[i].second; int l = 0, r = 1e9; while (abs(l - r) > 1) { int mid = (l + r) / 2; ll cnt = 0; rep(i, 0, n) { if (a[i].first <= mid && a[i].second >= mid) { cnt += mid - a[i].first + 1; } if(a[i].second= k) r = mid; else l = mid; } cout << l+1 << endl; return 0; }