#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, int> > allow;
  int n;
  cin >> n;
  int tmp_min = 10000000;
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    tmp_min = min(tmp_min, min(a, b));
    allow.push_back(pair<int, int>(a, b));
  }
  int tmp_max = 0;
  int ans = 0;
  for (int i = tmp_min; i <= n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      if (i >= allow[j].first && i <= allow[j].second) cnt++;
    }
    if (tmp_max <= cnt && i <= cnt) {
      tmp_max = cnt;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
