#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, k, f, t, max, c;
  cin >> n >> k >> f >> t;
  if (t > k)
    max = f - (t - k);
  else
    max = f;
  n--;
  while (n--) {
    cin >> f >> t;
    if (t > k)
      c = f - (t - k);
    else
      c = f;
    if (c > max) max = c;
  }
  cout << max;
  return 0;
}
