#include #include #include #include #include #include #include #include using namespace std; typedef long long int ll; typedef pair pos; const ll MOD = 1000000007,N=100010; ll n, m, fn = INT_MIN,fn2=INT_MIN; pos ab[N]; int main() { cin >> n >> m; for (ll i = 1,cfn=0; i <= n; i++) { cin >> ab[i].first >> ab[i].second; cfn += max(ab[i].first, ab[i].second); fn = max(cfn, fn); } for (ll i = 1, cfn2 = 0; i <= n; i++) { cfn2 += ab[i].first; fn2 = max(cfn2, fn2); } cout << fn + max((ll)0,fn2) * (m - 1) << endl; return 0; }