#include <bits/stdc++.h>
int64_t n, k;
int64_t f[11234], t[11234];
int64_t solve() {
  int64_t ans = -1e10;
  for (int i = 0; i < n; ++i) {
    if (t[i] > k) f[i] -= (t[i] - k);
    ans = std::max(ans, f[i]);
  }
  return ans;
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i) std::cin >> f[i] >> t[i];
  std::cout << solve();
  return 0;
}
