#include <bits/stdc++.h>
int main() {
  int i, j, n, k;
  while (scanf("%d %d", &n, &k) == 2) {
    int f, t, max = -2000000000;
    for (i = 0; i < n; i++) {
      scanf("%d %d", &f, &t);
      if (t > k) {
        if ((f - t + k) > max) max = f - t + k;
      } else {
        if (f > max) max = f;
      }
    }
    printf("%d\n", max);
  }
}
