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 print(meguru_bisect(0,10**9+100))