#include using namespace std; typedef long long ll; typedef pair l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; ll N, M; ll A[100050]; ll B[100050]; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); cin >> N >> M; for(int i = 1; i <= N; i++) cin >> A[i] >> B[i]; ll ans = 0; ll now = 0; int last = 0; for(int i = 1; i <= N; i++) { now += max(A[i], B[i]); if(ans <= now) { ans = max(ans, now); last = i; } } ll ans2 = 0; now = 0; for(int i = 1; i <= N; i++) { if(A[i] >= 0) { now += (M - 1) * A[i]; ans2 = max(ans2, now); continue; } if(B[i] >= A[i]) { if(last < i) now += B[i]; continue; } ll val = max((M - 1) * A[i], B[i]); if(last >= i) val = max(val, B[i] - A[i]); now += val; ans2 = max(ans2, now); } cout << ans + ans2 << endl; return 0; }