import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines N, M = map(int, readline().split()) m = map(int, read().split()) AB = zip(m, m) INF = 10 ** 18 dp = [0, 0, 0] # 0回、1回、M回 for i, (a, b) in enumerate(AB): newdp = [0, 0, 0] newdp[0] = max(dp) newdp[1] = max(dp[1:]) + max(a, b) full = a * (M - 1) + max(a, b) newdp[2] = dp[2] + max(full, b) dp = newdp if not i: dp[0] = -INF dp[1] = -INF print(max(dp))