#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, f, t, mx = -INFINITY;
  cin >> n >> k;
  while (n--) {
    cin >> f >> t;
    if (t > k) {
      mx = max(f - (t - k), mx);
    } else
      mx = max(f, mx);
  }
  cout << mx << endl;
}
