#include <bits/stdc++.h>
using namespace std;
long long int n, k, b[100001], ans = -999999999999;
int main() {
  pair<int, int> a[100001];
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    cin >> a[i].first >> a[i].second;
    if (a[i].second > k) {
      b[i] = a[i].first - (a[i].second - k);
    } else {
      b[i] = a[i].first;
    }
  }
  for (int i = 1; i <= n; i++) {
    ans = max(b[i], ans);
  }
  cout << ans;
  return 0;
}
