#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007, mod2 = 2e9;
double Pi = 3.141592653589793238;
unsigned long long gcd(unsigned long long a, unsigned long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
unsigned long long FP(unsigned long long b, unsigned long long p) {
  if (p == 0) return 1;
  return (p % 2 == 1) ? (b)*FP(b * b, p / 2) : FP(b * b, p / 2);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long n, t, a, b;
  cin >> n >> t;
  long long v = -1e9;
  for (int i = (0); i < (n); i++) {
    cin >> a >> b;
    if (b <= t)
      v = max(v, a);
    else {
      v = max(v, (a - (b - t)));
    }
  }
  cout << v;
}
