N,K = map(int,input().split()) edge = [] for _ in range(N): a,b = map(int,input().split()) edge.append((a,b)) def check(x): count = 0 for a,b in edge: if a <= x <= b: count += x - a + 1 elif x > b: count += b - a + 1 return count >= K start = 0 end = 10 ** 9 while end - start > 1: mid = (end + start) // 2 if check(mid): end = mid else: start = mid print(end)