#include <bits/stdc++.h>
using namespace std;
int main() {
  long long a, b, sum = 0, maxx = -100000000000000;
  scanf("%lld%lld", &a, &b);
  long long arr[a], arr2[a];
  for (long long z = 0; z < a; z++) {
    cin >> arr[z] >> arr2[z];
    if (arr2[z] > b) {
      sum = (arr[z] - (arr2[z] - b));
      if (maxx < sum) maxx = sum;
    } else {
      sum = arr[z];
      if (maxx < sum) maxx = sum;
    }
  }
  cout << maxx;
}
