def judge(x): cnt = 0 for Ai, Bi in AB: if Ai <= x <= Bi: cnt += x - Ai + 1 elif Bi < x: cnt += Bi - Ai + 1 if cnt >= K: return True else: return False def binary_search(): left, right = 0, 10 ** 18 while left <= right: mid = (left + right) // 2 if judge(mid): right = mid - 1 else: left = mid + 1 return left N, K = map(int, input().split()) AB = [tuple(map(int, input().split())) for _ in range(N)] ans = binary_search() print(ans)