#include <bits/stdc++.h>
int main() {
  long long int ch[100000];
  char arr[1000000];
  char kh[1000000], bh, ag;
  int cp[400000];
  long int a = 0, b, c, d, e = 0, g, i = 0, tep = 0, temp = 0, j = 0, k = 0,
           l = 0, m = 0, n = 0;
  scanf("%ld %ld", &a, &d);
  for (i = 0; i < a; i++) {
    j = 0;
    scanf("%ld%ld", &b, &c);
    j = c > d ? (b - (c - d)) : b;
    if (i == 0 || j > k) k = j;
  }
  printf("%ld\n", k);
  return 0;
}
