n,m=map(int,input().split()) dp=[[0,0,0] for _ in range(n)] a,b=map(int, input().split()) dp[0][0]=dp[0][1]=-10**18 dp[0][2]=max(m*a,b+(m-1)*a,b) for i in range(1, n): a,b=map(int,input().split()) dp[i][0]=max(dp[i-1]) dp[i][1]=max(dp[i-1][1:])+max(a,b) dp[i][2]=dp[i-1][2]+max(m*a,b+(m-1)*a,b) print(max(dp[-1]))