#include <bits/stdc++.h>
using namespace std;
struct f {
  int ord;
  int num;
};
int comp(f a, f b) { return a.num < b.num; }
int main() {
  int k, time, m;
  int x, y, i, j, n, b[2000];
  scanf("%d %d", &time, &k);
  scanf("%d %d", &x, &y);
  if (y > k) {
    m = x - (y - k);
  } else {
    m = x;
  }
  time--;
  while (time--) {
    scanf("%d %d", &x, &y);
    if (y > k) {
      if (m < x - (y - k)) m = x - (y - k);
    } else {
      if (m < x) m = x;
    }
  }
  printf("%d\n", m);
}
