#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll (i)=a;(i)<(b);++(i)) #define RFOR(i,a,b) for(ll (i)=a;(i)>=(b);--(i)) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,n,0) #define ALL(v) v.begin(), v.end() #define UNIQ(v) sort(ALL(v)); v.erase(unique(ALL(v)), v.end()) #define BIT(n) (1LL<<(n)) #define DEBUG(a) cout << #a << " = " << a << endl const ll inf = 1e15; const ll mod = 1e9+7; int dy[] = {0, 0, 1, -1}; int dx[] = {1, -1, 0, 0}; int main() { int N, K; vector A, B; cin >> N >> K; REP(i, N) { int a, b; cin >> a >> b; A.push_back(a); B.push_back(b); } sort(A.begin(), A.end()); sort(B.begin(), B.end()); int count = 0; for (ll i = 1; i <= 1e9; i++) { auto iter = upper_bound(ALL(A), i); auto iter2 = lower_bound(ALL(B), i); int inc_num = iter - A.begin(); int dec_num = iter2 - B.begin(); count += inc_num - dec_num; if (count >= K) { cout << i << endl; return 0; } } }