#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair P; typedef pair E; #define MOD (1000000007ll) #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } void add_mod(ll& a, ll b){ a += b; a %= MOD; } ll a[100100],b[100100],s[100100]; int main(void){ int n,i; ll m,ans,p=0ll,q=0ll; cin >> n >> m; for(i=0; i> a[i] >> b[i]; } for(i=(n-1); i>=0; --i){ p += a[i]; q += max(b[i]-a[i],0ll); if(p<0ll){ q += p; q = max(0ll,q); p = 0ll; } } ans = max(p+q,p*m+q); cout << ans << endl; return 0; }