#include <bits/stdc++.h>
const int MAXN = 1e5 + 5;
const long long MOD = 998244353;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1);
const double ERR = 1e-10;
const int L = 40;
const int M = 30;
using namespace std;
long long mx = -1e18;
long long mn = 1e18;
int main() {
  ios_base::sync_with_stdio(NULL);
  cin.tie(NULL);
  cout.tie(NULL);
  long long a, b, c[MAXN], d[MAXN];
  cin >> a >> b;
  for (int i = 1; i <= a; i++) {
    cin >> c[i] >> d[i];
  }
  for (int i = 1; i <= a; i++) {
    if (d[i] > b) {
      c[i] = c[i] - (d[i] - b);
    }
  }
  cout << *max_element(c + 1, c + 1 + a);
  return 0;
}
