#include using namespace std; using ll = long long int; using ull = unsigned long long int; using ld = long double; constexpr ll MAX = 2000000000000000000; constexpr ld PI = 3.14159265358979; constexpr ll MOD = 0;//2024948111; ld dotorad(ld K){return PI * K / 180.0;} ld radtodo(ld K){return K * 180.0 / PI;} mt19937 mt; void randinit(){srand((unsigned)time(NULL));mt = mt19937(rand());} int main(){ ll N,D,ans = -MAX; cin >> N >> D; vector P(N),Q(N); for(ll i = 0;i < N;i++) cin >> P[i] >> Q[i]; for(ll i = 0;i < N;i++) for(ll j = 0;j < N;j++) if(i != j){ ll m = min(-P[i],Q[i] - P[i] - Q[j]); ll s = Q[i] + Q[j] - P[i] - P[j]; if(s >= 0){ ans = max(ans,m); } else{ if(D % 2 == 0){ ll p = s * (D / 2 - 1); ans = max(ans,p + m); } else{ ll p = s * (D / 2 - 1); ans = max(ans,p - P[i]); } } } cout << ans << endl; }