INF = 10 ** 9 MOD = 10 ** 9 + 7 import sys sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from math import factorial def f(x,C): S = 0 t = 0 for a,b in C: if x < a: continue if b < x: S += b - a + 1 elif a <= x <= b: S += x - a t += 1 return S,t def main(): n,k = map(int,input().split()) C = [tuple(map(int,input().split())) for _ in range(n)] l = 0 r = 10 ** 9 + 1 while r - l > 1: mid = (r + l)//2 S,t = f(mid,C) if S < k <= S + t: break if S >= k: r = mid else: l = mid print(mid) if __name__ == '__main__': main()