#include <bits/stdc++.h>
using namespace std;
int n, k;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  int ans = -1e9 - 3;
  for (int i = 0, f, t; i < n; ++i) {
    cin >> f >> t;
    int joy;
    if (t <= k)
      joy = f;
    else
      joy = f - (t - k);
    ans = max(ans, joy);
  }
  cout << ans;
}
