#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, k, t, f, ans, mxm, i;
  cin >> n >> k;
  mxm = -1000000000;
  for (i = 0; i < n; i++) {
    cin >> f >> t;
    if (t > k) {
      ans = f - (t - k);
    } else
      ans = f;
    mxm = ((ans > mxm) ? ans : mxm);
  }
  cout << mxm << endl;
}
