def main(): N, D = map(int, input().split()) max_tokyo = 0 max_kyoto = D * ( -1 ) for i in range(N): T, K = map(int, input().split()) tmp_max_tokyo = max_tokyo tmp_max_kyoto = max_kyoto max_tokyo = T + max(tmp_max_tokyo, tmp_max_kyoto - D) max_kyoto = K + max(tmp_max_tokyo - D, tmp_max_kyoto) #print(max_tokyo, max_kyoto) if max_tokyo > max_kyoto: print(max_tokyo) else: print(max_kyoto) if __name__ == '__main__': main()