#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k;
  cin >> n >> k;
  long long joy = INT_MIN;
  for (long long i = 0; i < n; ++i) {
    long long f, t;
    cin >> f >> t;
    if (t > k) {
      joy = max(joy, f - (t - k));
    } else {
      joy = max(joy, f);
    }
  }
  cout << joy;
  return 0;
}
