#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, f, t;
  priority_queue<int> p;
  scanf("%d %d", &n, &k);
  while (n--) {
    scanf("%d %d", &f, &t);
    p.push(f - max(0, t - k));
  }
  cout << p.top();
  return 0;
}
