#include <bits/stdc++.h>
using namespace std;
int n, k, f, t, mx = -2 * 1000 * 1000 * 1000;
int main() {
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> f >> t;
    mx = max(mx, f - (max(0, t - k)));
  }
  cout << mx;
  return 0;
}
