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(0, N+1): if k < N: S[k] += np.cumsum(np.concatenate([[0], S1[k+1:]])).max() print(S.max())