#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, i, f, t, temp;
  long long int val = -99999999999;
  cin >> n >> k;
  while (n--) {
    cin >> f >> t;
    if (k >= t) {
      if (val < f) val = f;
    } else {
      temp = f - t + k;
      if (val < temp) val = temp;
    }
  }
  cout << val << endl;
  return 0;
}
