#include <bits/stdc++.h>
using namespace std;
bool a_sec(const pair<int, int> &a, const pair<int, int> &b) {
  return a.second < b.second;
}
void solve() {
  int n, k;
  cin >> n >> k;
  int ans = INT_MIN + 1;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (b > k)
      ans = max(a - b + k, ans);
    else
      ans = max(ans, a);
  }
  cout << ans;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
}
