#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > a;
  int mx = -1e9;
  for (int i = 0; i < n; i++) {
    int f, t;
    cin >> f >> t;
    if (t <= k)
      mx = max(mx, f);
    else
      mx = max(mx, f - t + k);
    a.push_back(make_pair(f, t));
  }
  cout << mx << endl;
  return 0;
}
