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