#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  long long n, k, f, t, ma = -10000000000;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> f >> t;
    if (t > k)
      ma = max(ma, f - (t - k));
    else
      ma = max(ma, f);
  }
  cout << ma << endl;
  return 0;
}
