#include <bits/stdc++.h>
using namespace std;
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
const double EPS = 1e-10;
const double PI = acos(-1.0);
int main() {
  long n, k;
  long maxjoy(LONG_MIN);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    long f, t, tmpmax(0);
    cin >> f >> t;
    tmpmax = f - max(t - k, 0L);
    maxjoy = max(maxjoy, tmpmax);
  }
  cout << maxjoy << endl;
  return 0;
}
