n, d = map(int, input().split()) t, k = map(int, input().split()) tokyo, kyoto = t, k - d for i in range(n-1): t, k = map(int, input().split()) t_i = max(tokyo, kyoto - d) + t k_i = max(tokyo - d, kyoto) + k tokyo = t_i kyoto = k_i print(max(tokyo, kyoto))