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