#include <bits/stdc++.h>
using namespace std;
void maximum_joy(long n, long long k, long long f[], long long t[]) {
  long long m = -1000000000;
  for (long i = 0; i < n; i++) {
    if (t[i] > k)
      m = max(m, f[i] - (t[i] - k));
    else
      m = max(m, f[i]);
  }
  cout << m;
}
int main() {
  long n;
  long long k;
  cin >> n >> k;
  long long f[n], t[n];
  long i;
  for (i = 0; i < n; i++) {
    cin >> f[i] >> t[i];
  }
  maximum_joy(n, k, f, t);
  return 0;
}
