n,m = map(int,input().split()) ab = [list(map(int,input().split())) for _ in range(n)] X,Y,Z,W = [0]*4 for a,b in ab: x = a*m y = a*(m-1) + b X,Y,Z,W = X+max(x,y), max(X,Y)+max(a+b,b), max(X,Y,Z)+max(a,b), max(X,Y,Z,W) print(max(X,Y,Z,W))