#include <bits/stdc++.h>
using namespace std;
int n, k, f, t, mx;
int main() {
  scanf("%d%d", &n, &k);
  scanf("%d%d", &f, &t);
  mx = t > k ? f - (t - k) : f;
  for (int f, t, x, i = 0; i < n - 1; ++i) {
    scanf("%d%d", &f, &t);
    x = t > k ? f - (t - k) : f;
    if (x > mx) mx = x;
  }
  printf("%d\n", mx);
  return 0;
}
