#include <bits/stdc++.h>
using namespace std;
long long n, k, x, y, rez = -1LL << 43;
int main() {
  cin >> n >> k;
  while (n--) {
    cin >> x >> y;
    if (y <= k)
      rez = max(rez, x);
    else
      rez = max(rez, x - (y - k));
  }
  cout << rez;
}
