#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

// Sieve of Eratosthenes
// https://youtu.be/UTVg7wzMWQc?t=2774
struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) { return f[x] == x; }
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<P> res(1, P(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    vector<pair<ll, int>> factor(ll x) {
        vector<pair<ll, int>> res;
        for (int p : primes) {
            int y = 0;
            while (x % p == 0) x /= p, ++y;
            if (y != 0) res.emplace_back(p, y);
        }
        if (x != 1) res.emplace_back(x, 1);
        return res;
    }
};

ll A, B;
unordered_map<ll, int> mp;
ll dp[1 << 20][74];

ll dfs(ll t, int mask) {
    if (dp[mask][t - A] != 0) {
        return dp[mask][t - A];
    }
    if (t > B) {
        return dp[mask][t - A] = 1;
    }

    int tmask = mp[t];
    ll retVal = 0;
    // cerr << "tmask =" << tmask << "bit wise=" << bitset<20>(mask & tmask) << endl;
    if ((mask & tmask) == 0) {
        retVal += dfs(t + 1, mask | tmask);
    }
    retVal += dfs(t + 1, mask);
    return dp[mask][t - A] = retVal;
}

void solve() {
    Sieve sieve(72);
    for (ll i = A; i <= B; i++) {
        int mask = 0;
        rep(j, sieve.primes.size()) {
            if (i % sieve.primes[j] == 0) {
                mask |= (1 << j);
            }
        }
        // cerr << "i=" << i << " mask=" << mask << endl;
        mp[i] = mask;
    }
    dfs(A, 0);
    cout << dp[0][0] << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    scanf("%lld", &A);

    scanf("%lld", &B);
    solve();
    return 0;
}

#include <bits/stdc++.h>

using namespace std;
using ll =unsigned long long;
typedef pair<ll,ll> P;
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
void mswap(ll &a, ll &b){ if(a >= b) swap(a,b); }
void rswap(ll &a, ll &b){ if(a <= b) swap(a,b); }

const int dy[] = {0,0,1,-1};
const int dx[] = {1,-1,0,0};
const ll mod = 1e9+7;
const ll MOD = 998244353;
const double PI=3.14159265358979323846;
const int inf = 1001001001;
const ll INF = 1e18;
//Write From this Line
int main()
{
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	rep(i,n) cin >> a[i] >> b[i];
	int ans = inf;
	rep(i,n){
		rep(j,n){
			if(i == j){
				chmin(ans, a[i] + b[j]);
			}else{
				chmin(ans, max(a[i],b[j]));
			}
		}
	}
	cout << ans << endl;
}
