#include <bits/stdc++.h>
using namespace std;
bool isPrime(long long n) {
  if (n == 2) return true;
  if (n < 2 || n % 2 == 0) return false;
  for (long long i = 3; i * i <= n; i += 2) {
    if (n % i == 0) return false;
  }
  return true;
}
void Allah_fowk_kyd_el_mo3tden() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
struct cir {
  char ad;
  long long int x, y, rad;
};
string is(long long x) {
  string s;
  stringstream ss;
  ss << x;
  ss >> s;
  return s;
}
long long si(string n) {
  stringstream geek(n);
  long long x = 0;
  geek >> x;
  return x;
}
using namespace std;
int main() {
  Allah_fowk_kyd_el_mo3tden();
  long long n, k;
  cin >> n >> k;
  long long x, y, res = INT_MIN;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (y <= k)
      res = max(res, x);
    else
      res = max(res, x - (y - k));
  }
  cout << res << endl;
  return 0;
}
