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