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