#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int maxi = -1000000050;
  int f, t;
  int loli = -1000000050;
  for (int i = 0; i < n; i++) {
    cin >> f >> t;
    if (t > k) {
      loli = f - (t - k);
    } else
      loli = f;
    if (loli > maxi) maxi = loli;
  }
  cout << maxi << endl;
  return 0;
}
