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