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