#include <bits/stdc++.h>
using namespace std;
vector<long long int> vv;
int main() {
  long long int i, j, n, k, ff, tt, dif;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> ff >> tt;
    dif = tt - k;
    if (dif >= 0)
      vv.push_back(ff - (tt - k));
    else
      vv.push_back(ff);
  }
  sort(vv.begin(), vv.end());
  cout << vv[n - 1] << endl;
  return 0;
}
