#include using namespace std; //#include //using namespace atcoder; typedef long long ll; typedef unsigned long long ull; const int MAX = 1e9; const int MIN = -1*1e9; const ll MAXLL = 1e18; const ll MINLL = -1*1e18; //const ll MOD = 998244353; //const ll MOD = 1000000007; int main() { int N,M; cin >> N >> M; vector> P(N); for(int i = 0; i < N; i++) { cin >> P[i].second >> P[i].first; } sort(P.begin(),P.end()); int Ans = -1; for(int i = 0; i < N; i++) { if(P[i].first > M) break; Ans = max(Ans,P[i].second); } cout << Ans << endl; return 0; }