#include <bits/stdc++.h>
using namespace std;
map<string, int> mymap;
int n, k, t, f, maxi = -1000000000 + 1;
int main() {
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", &f, &t);
    if (t > k) f -= (t - k);
    maxi = max(maxi, f);
  }
  printf("%d\n", maxi);
}
