#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, f, t, sum = -999999999, m, x, i;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> f >> t;
    if (k < t) {
      m = f - (t - k);
    } else {
      m = f;
    }
    x = max(sum, m);
    sum = x;
  }
  cout << x << endl;
}
