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