#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  long long int n, k, fi, ti, joy = numeric_limits<long long int>::min();
  cin >> n >> k;
  for (long long int i = 0; i < n; i++) {
    cin >> fi >> ti;
    if (ti <= k)
      joy = max(joy, fi);
    else
      joy = max(joy, (fi - ti + k));
  }
  cout << joy;
  return EXIT_SUCCESS;
}
