#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
  return (a % b) == 0 ? b : GCD(b, a % b);
}
long long mod(long long x) { return ((x % 998244353 + 998244353) % 998244353); }
bool cmp(const pair<int, int> &left, const pair<int, int> &right) {
  return left.first > right.first ||
         (left.first == right.first && left.second < right.second);
}
int main() {
  long long n, m, a, b, c, i, j, k, mx = INT_MIN, mn = 1e18;
  long long ar[100005];
  cin >> n >> k;
  for (i = 0; i < n; i++) {
    cin >> a >> b;
    mx = max(mx, (b > k ? a - (b - k) : a));
  }
  cout << mx << endl;
  return 0;
}
