#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  long long maxi;
  maxi = -9999999999;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int a, b;
    long long tmp;
    cin >> a >> b;
    if (b > k) {
      tmp = a - (b - k);
    } else {
      tmp = a;
    }
    maxi = max(tmp, maxi);
  }
  cout << maxi;
}
