n,d=map(int,input().split()) food=[] for _ in range(n): p,q=map(int,input().split()) food.append([-p,q,q-p]) food.sort() las=food[-1][0] ans=-10**9+1 for i in range(n): for j in range(n): if i==j: continue T=food[i][2]+food[j][2] tmp=min(food[i][0],food[i][2]+food[j][0]) if T<0: if tmp==food[i][0]: if d%2==0: tmp=T*(d//2-1)+food[i][0] else: tmp=T*((d-1)//2)+las else: if d%2==0: tmp=T*(d//2-1)+tmp else: tmp=T*((d-1)//2)+min(las,-food[j][1]) ans=max(ans,tmp) print(ans)