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