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) S0 = np.cumsum(S0) S1 = np.cumsum(S1) S2 = S1.max() - S1 S = S0 + S2 print(S.max())