N, K = map(int,input().split()) query = [] for i in range (N) : L, R = map(int,input().split()) query.append([L,R]) ok = 10**9 ng = 0 while ok - ng > 1 : mid = (ok + ng) // 2 cnt = 0 for L, R in query : if L > mid : continue cnt += min(R, mid) - L + 1 if cnt >= K : ok = mid else : ng = mid print(ok)