import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long k = sc.nextLong(); long[] a = new long[n]; long[] b = new long[n]; for(int i = 0; i < n; i++) { a[i] = sc.nextLong(); b[i] = sc.nextLong(); } long l = 1; long r = (long)Math.pow(10, 9) + 1; long ans = 0; while(l < r) { long med = (l + r) / 2; long t = 0; for(int i = 0; i < n; i++) { if(a[i] <= med) { if(b[i] <= med) { t += (b[i] - a[i] + 1); } else { t += (med - a[i] + 1); } } } if(t >= k) { ans = med; r = med; } else { l = med + 1; } } System.out.println(ans); } }