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) dp = [0, 0, 0] # 0回、1回、M回 for a, b in 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 print(max(dp))