#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  long long maxmVal = INT_MIN;
  for (long long i = 0; i < n; i++) {
    long long f, t;
    long long ans;
    cin >> f >> t;
    if (t > k)
      ans = f - t + k;
    else
      ans = f;
    maxmVal = max(ans, maxmVal);
  }
  cout << maxmVal << "\n";
}
