N,K = map(int,input().split()) AB = [] for i in range(N): AB.append(list(map(int,input().split()))) def is_ok(v): temp = 0 for a,b in AB: temp+=max(0,min(v,b)-a+1) return temp>=K def meguru_bisect(ng, ok): while (abs(ok - ng) > 1): mid = (ok + ng) // 2 if is_ok(mid): ok = mid else: ng = mid return ok ok = meguru_bisect(0,10**9+100) ans = 0 for a,b in AB: if a<=ok<=b: ans = max(ans,min(b,ok)) print(ans)