#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k, f, t, ans, max1 = -1000000000;
  cin >> n >> k;
  while (n--) {
    cin >> f >> t;
    if (t <= k)
      ans = f;
    else
      ans = f - (t - k);
    max1 = max(ans, max1);
  }
  cout << max1;
}
