#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  vector<long long> v;
  long long n, k, sum = 0, max = INT_MIN;
  cin >> n >> k;
  for (int c = 0; c < n; c++) {
    long long f, t;
    cin >> f >> t;
    if (t > k) {
      sum = f - (t - k);
      v.push_back(sum);
    } else {
      v.push_back(f);
    }
  }
  vector<long long>::iterator it;
  for (it = v.begin(); it != v.end(); it++) {
    if (max < (*it)) {
      max = (*it);
    }
  }
  cout << max << endl;
  return 0;
}
