N,K = map(int, input().split()) AB = [list(map(int, input().split())) for _ in range(N)] ok = 10**9 ng = 0 mid = (ok+ng)//2 while abs(ok-ng) > 1: tmpCount = 0 for a,b in AB: n = b-a+1 if b < mid: tmpCount += n elif mid < a: pass elif a <= mid <= b: tmpCount += mid - a + 1 if tmpCount >= K: ok = mid else: ng = mid mid = (ok+ng)//2 print(ok)