#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

struct Fast {
  Fast() {
    std::cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(10);
  }
} fast;

#define rep(i, a, b) for (int(i) = (a); (i) < (int)(b); (i)++)

int main() {
  int n, wmax;
  cin >> n >> wmax;
  int ans = -1;
  rep(i, 0, n) {
    int v, w;
    cin >> v >> w;
    if (w > wmax) v = -1;
    ans = max(ans, v);
  }
  cout << ans << endl;
}