#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> joy;
  while (n > 0) {
    int f, t;
    cin >> f >> t;
    if (t > k) f = f - t + k;
    joy.push_back(f);
    n--;
  }
  sort(joy.begin(), joy.end());
  cout << joy.back();
}
