#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, mx = -1e9, tmp;
  cin >> n >> k;
  pair<int, int> p[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i].first >> p[i].second;
    if (k >= p[i].second) {
      if (p[i].first > mx) mx = p[i].first;
    } else {
      tmp = p[i].first - (p[i].second - k);
      if (tmp > mx) mx = tmp;
    }
  }
  cout << mx;
}
