#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int f[n], t[n];
  int joy, maxjoy = -1e9;
  for (int i = 0; i < n; i++) {
    cin >> f[i] >> t[i];
    if (t[i] > k) {
      joy = f[i] - (t[i] - k);
    } else {
      joy = f[i];
    }
    maxjoy = max(joy, maxjoy);
  }
  cout << maxjoy;
  return 0;
}
