#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, a[10005], b[10005], i, j, max;
  scanf("%d%d", &n, &k);
  for (i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
    if (b[i] > k) a[i] = a[i] - (b[i] - k);
    if (i == 0)
      max = a[i];
    else
      max = a[i] > max ? a[i] : max;
  }
  cout << max;
  return 0;
}
