import numpy as np A = [] B = [] N, M = map(int, input().strip().split(' ')) for i in range(N): a, b = map(int, input().strip().split(' ')) A.append(a) B.append(b) A = np.array(A, dtype=np.int64) B = np.array(B, dtype=np.int64) S0 = np.maximum(np.maximum(A * M, A * (M - 1) + B), B) S1 = np.maximum(A, B) S = np.cumsum(S0) for k in range(1, N+1): if k > N-2: continue S[k] += np.cumsum(S1[k:])[1:].max() print(S[1:].max())