#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int i, n, k, m = -1000000000000000, x, y, sum = 0;
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> x >> y;
    if (y >= k) {
      sum = x - (y - k);
      m = max(m, sum);
    }
    if (y < k) {
      sum = x;
      m = max(m, sum);
    }
    sum = 0;
  }
  cout << m;
  return 0;
}
