import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(2*10**5+10) write = lambda x: sys.stdout.write(x+"\n") debug = lambda x: sys.stderr.write(x+"\n") writef = lambda x: print("{:.12f}".format(x)) n,m = list(map(int, input().split())) ab = [list(map(int, input().split())) for _ in range(n)] v0 = [max(a,b) for a,b in ab] v1 = [max(m*a, (m-1)*a+b, b) for a,b in ab] cummax = 0 cum0 = 0 cum1 = 0 ans = -float("inf") for j in range(n): cum0 += v0[j] ans = max(ans, cum0 + cummax) # print(cum0, cummax) cum1 += v1[j] cummax = max(cummax, -cum0 + cum1) ans = max(ans, cum0 + cummax) print(ans)