#include"bits/stdc++.h" using namespace std; using ll = long long; using ld = long double; using pii = pair; using pll = pair; #define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++) #define REP(i,n) FOR((i),0,(n)) #define WAITING(str) int str;std::cin>>str; #define DEBUGING(str) cout<< #str << " " str<> N >> K; vector> abs(N); REP(i, N) { ll a, b; cin >> a >> b; abs[i] = { a,b }; } sort(abs.begin(), abs.end()); ll l = 0, r = 1e9 + 10; while (r - l > 1) { ll mid = (l + r) / 2; ll num = 0; for (auto ab : abs) { ll a = ab.first; ll b = ab.second; if (mid < a)continue; if (b < mid) { num += (b - a + 1); } else { num += (mid - a + 1); } } if (num < K)l = mid; else r = mid; } cout << r << endl; return 0; }