import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np data = np.fromstring(read(), np.int64, sep=' ') N, K = data[:2] AB = data[2:] A = AB[::2] B = AB[1::2] def f(x): """count coins <= x""" return np.maximum(0, 1 + np.minimum(x, B) - A).sum() left = 0 right = 10 ** 9 while left + 1 < right: x = (left + right) // 2 if f(x) >= K: right = x else: left = x print(right)