import java.util.*; public class Main { public static void main (String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int d = sc.nextInt(); int prevT = sc.nextInt(); int prevK = sc.nextInt() - d; for (int i = 1; i < n; i++) { int nextT = sc.nextInt() + Math.max(prevT, prevK - d); int nextK = sc.nextInt() + Math.max(prevT - d, prevK); prevT = nextT; prevK = nextK; } System.out.println(Math.max(prevT, prevK)); } }