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