
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int mod = 1e9+7;
#define vi vector<int>
#define pb push_back
#define ff first
#define ss second
#define pi pair<int,int>
#define all(v) (v).begin(),(v).end()
#define mk(arr,n,type)  type *arr=new type[n];
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define repm(i,a,b) for(int i=a ; i<b ; i++)
int gcd(int a , int b){
  if(b==0) return a;

  return gcd(b,a%b);
}

void cp(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
  #endif
}

void solve(){

  int n;
  cin>>n;

  vector<pi> vec;

  rep(i,n){
    int x,y;
    cin>>x>>y;
    vec.pb({x,y});
  }

  if(n==1){
    cout<<vec[0].ff+vec[0].ss<<endl;
    return ;
  }

  int mini1 = INT_MAX , mini2 = INT_MAX , mini = INT_MAX;

  int idx,idx1;

  rep(i,n){
      if(mini1 > vec[i].ff){
        mini1 = vec[i].ff;
        idx = i;
      }
  }

  rep(i,n){
      if(idx==i)continue;

      if(mini2 > vec[i].ss){
        idx1 = i;
        mini2 = vec[i].ss;
      }
  }

  mini = max(mini1,mini2);

  rep(i,n){
    mini = min(mini,vec[i].ff + vec[i].ss);
  }

  cout<<mini<<endl;

}          


int32_t main(){
  cp();
  int t = 1;
  // cin>>t;

  while(t--)
    solve();

    return 0;
}



#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<vector>
using namespace std;

int main(){
    int64_t n;
    int64_t k;
    cin >> n;
    cin >> k;

    vector<pair<int64_t, int64_t> > ab(n);
    int64_t a;
    int64_t b;

    for(int64_t i=0; i<n; i++){
        cin >> a;
        cin >> b;

        ab.at(i).first = a;
        ab.at(i).second = b;

    }
    sort(ab.begin(), ab.end());

    int64_t mura = 0;
    int64_t nowmoney = 0;
    mura += k;



    for(int64_t i=0; i<n; i++){


        if(mura >= ab.at(i).first){
            mura += ab.at(i).second;
            nowmoney += ab.at(i).second;
        }
    }

    cout << mura << endl;
    


    

}