import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) N, K = map(int, input().split()) AB = tuple(tuple(map(int, input().split())) for _ in range(N)) def C(x): cnt = 0 for a, b in AB: if x < a: continue b = min(b, x) cnt += b - a + 1 return cnt >= K l = 0 r = 10 ** 9 + 2 while r - l > 1: m = (r + l) // 2 if C(m): r = m else: l = m print(r)