from collections import defaultdict from heapq import heappop, heappush def getlist(): return list(map(int, input().split())) N, K = getlist() D = defaultdict(int) for i in range(N): A, B = getlist() D[A] += 1 D[B + 1] -= 1 L = [] for i in D: L.append([i, D[i]]) L = sorted(L) Kval = K n = 0 for i in range(len(L) - 1): n += L[i][1] a = L[i][0] b = L[i + 1][0] if (b - a) * n >= Kval: print(a + int((Kval - 1) // n)) break else: Kval -= (b - a) * n