#include using namespace std; typedef long long ll; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define loop(i, a, b) for (int i = a; i < (int)(b); i++) int main() { ll N, K; cin >> N >> K; ll A[N]; ll B[N]; rep(i, N) { cin >> A[i]; cin >> B[i]; B[i]++; } sort(A, A + N); sort(B, B + N); int aidx = 0; int bidx = 0; ll diff = 0; ll last = 0; ll count = 0; while (true) { if (aidx >= N || B[bidx] <= A[aidx]) { ll c2 = count + (B[bidx] - last) * diff; if (c2 >= K) { ll dd = (K - count - 1) / diff; ll ans = last + dd; cout << ans << endl; break; } count = c2; diff--; last = B[bidx]; bidx++; if (bidx >= N) { break; } } else { ll c2 = count + (A[aidx] - last) * diff; if (c2 >= K) { ll dd = (K - count - 1) / diff; ll ans = last + dd; cout << ans << endl; break; } count = c2; diff++; last = A[aidx]; aidx++; } } return 0; }