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