n,m=map(int,input().split()) dp=[[0,0,0] for _ in range(n)] for i in range(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) if n==1: print(dp[-1][-1]) else: print(max(dp[-1]))