import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int k = sc.nextInt(); int[] aArr = new int[n]; int[] bArr = new int[n]; for (int i = 0; i < n; i++) { aArr[i] = sc.nextInt(); bArr[i] = sc.nextInt(); } int left = 0; int right = 1000000001; while (right - left > 1) { int m = (left + right) / 2; long sum = 0; for (int i = 0; i < n; i++) { sum += Math.max(Math.min(bArr[i], m) - aArr[i] + 1, 0); } if (sum <= k - 1) { left = m; } else { right = m; } } System.out.println(left + 1); } }