def bsearch(low: int, high: int, fun, is_complement=False) -> int: def pred(x: int) -> bool: return not fun(x) if is_complement else fun(x) lo = low hi = high res = low while lo <= hi: m = (lo + hi) // 2 if pred(m): res = max(res, m) lo = m + 1 else: hi = m - 1 return res + 1 if is_complement else res # m 円以下が K 枚以上あるか def calc(m: int) -> bool: res = 0 for a, b in xs: if m < a: continue res += min(m, b) - a + 1 if res >= K: return True return False N, K = map(int, input().split()) xs = [] for _ in range(N): A, B = map(int, input().split()) xs.append((A, B)) ans = bsearch(1, 10**9, calc, is_complement=True) print(ans)