#include <bits/stdc++.h>
using namespace std;
int readi() {
  int n = 0, sign = false;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') sign = true;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    n = n * 10 + c - '0';
    c = getchar();
  }
  if (sign) return -n;
  return n;
}
long long readl() {
  long long n = 0, sign = false;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') sign = true;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    n = n * 10 + c - '0';
    c = getchar();
  }
  if (sign) return -n;
  return n;
}
int main() {
  int n, k, x, y, ans = INT_MIN;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> x >> y;
    if (y > k) {
      ans = max(ans, x - (y - k));
    } else {
      ans = max(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}
