#include<iostream>
#include<algorithm>
using namespace std;
const long long MAXM = 50005;
pair <long long, long long> subitiq[MAXM];
int main (){
    long long st = 10000000, en = 0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    long long N;
    cin>>N;
    long long in = 0;
    for(long long i = 0; i < N; i++){
        long long a, b;
        cin>>a>>b;
        /*subitiq[in].first = a;
        subitiq[in].second = 1;
        subitiq[in+1].first = b;
        subitiq[in+1].second = -1;*/
        in+=2;
        if(st > a){
            st = a;
        }
        if( en < b){
            en = b;
        }
    }
    long long br = 0, maxbr = 0;
    /*sort(subitiq, subitiq + in);
    for(long long i = 0; i < in; i ++){
        br += subitiq[i].second;
        if(br > maxbr){
            maxbr = br;
        }
    }
    br = 0;
    long long tekbr = 0, maxdul = 0;
    long long x = 0;
    for(long long i = st; i <= en; i++){
        ///cout<<br<<endl;
        ///cout<<subitiq[x].first<<" "<<i<<endl;
        while(x < in && subitiq[x].first == i){
            ///cout<<"tuk "<<x<<endl;
            br+=subitiq[x].second;
            x++;
        }
        if(br == maxbr){
            tekbr++;
        }
    }*/
    ///cout<<maxbr<<endl<<tekbr;
    return 0;
}
/**
6
7 9
5 6
1 4
7 9
1 8
2 6
*/
