#include <bits/stdc++.h>

using namespace std;
#define sz(x) (int)((x).size())
#define forn(i,n) for (int i=0; i < n; i++)
#define forse(i,s,e) for (int i=s; i < e; i++)
#define pb push_back
#define fi first
#define se second
#define all(vec) vec.begin(), vec.end()
#define time() ((double)clock() / CLOCKS_PER_SEC)

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

double PI=3.141592653589793;

const int P = 998244353;
//Modular arithmetic
class mint{
	public:
		static int init_siz;
		static vector<mint> inverse,factorial;
		static int mintP;
		int n;
		static mint exp(mint a, long long e) {
			mint res = 1; while (e) { if (e&1) res *= a; a *= a; e >>= 1; }
			return res;
		}
		static void init(int n){
			init_siz=n;
			inverse.resize(n+1);factorial.resize(n+1);
			factorial[0] = 1;
			for (int i = 1; i <= n; i++) factorial[i] = factorial[i - 1] * i;
			inverse[n]=exp(factorial[n],mintP-2);
			for (int i = n-1; i>=0; i--) inverse[i] = inverse[i+1] * (i+1);
		}
		static mint inv(mint const& a){return (init_siz>=a.n? inverse[a.n]*(a.n>1?fac(a-1):1):exp(a,mintP-2));}
		static mint cinv(mint const& a){return (init_siz>=a.n? inverse[a.n]:exp(fac(a),mintP-2));}
		static mint fac(mint const& a){
			if(init_siz>=a.n) return factorial[a.n];
			else{
				mint out=1;
				for(int i=0;i<a.n;i++) out*=(i+1);
				return out;
			}
		}
		mint(long long val = 0) {n=val%mintP;if(n<0) n+=mintP;}
		mint& operator+=(mint const& b) {n += b.n; if (n >= mintP) n -= mintP; return *this;}
		mint& operator-=(mint const& b) {n -= b.n; if (n < 0) n += mintP;return *this;}
		mint& operator*=(mint const& b) {n = (long long)n * b.n % mintP;return *this;}
		mint exp(long long e) {return exp(*this,e);}
		mint inv(){return inv(*this);}
		mint& operator/=(mint const& b){ return *this *=inv(b);}	
		friend std::ostream& operator<<(std::ostream& os,mint const& a) {return os << (a.n<0?a.n+mintP:a.n);}
		friend mint operator+(mint a, mint const b) { return a += b; }
		friend mint operator-(mint a, mint const b) { return a -= b; }
		friend mint operator-(mint const a) { return 0 - a; }
		friend mint operator*(mint a, mint const b) { return a *= b; }
		friend mint operator/(mint a, mint const b) { return a /= b; }
		friend bool operator==(mint const& a, mint const& b) {return a.n == b.n;}
		friend bool operator!=(mint const& a, mint const& b) {return a.n != b.n;}
};
int mint::init_siz=0;
int mint::mintP=P;
vector<mint> mint::factorial,mint::inverse;


void solve(){
	int n;
	cin >> n;
	vector<int> ab(n),ba(n);
	vector<int> vals;
	forn(i,n){
		int a,b;
		cin >> a >> b;
		vals.pb(a-1);
		vals.pb(a+1);
		vals.pb(b-1);
		vals.pb(b+1);
		vals.pb(a);
		vals.pb(b);
		ab[i]=a;
		ba[i]=b;
	}	
	sort(all(vals));
	sort(all(ab));
	sort(all(ba));
	vals.resize(unique(all(vals))-vals.begin());
	int inda=0,indb=0;
	int ans=0;
	int lol=-1,hil=-1,lor=-1,hir=-1;
	forn(i,sz(vals)){
		while(indb<n&&ba[indb]<vals[i]) indb++;
		while(inda<n&&ab[inda]<=vals[i]) inda++;
		int lo=indb,hi=(n-inda);
		int md=(n-lo-hi);
		int cnt;
		if(i<sz(vals)-1) cnt=(vals[i+1]-vals[i]);
		else cnt=1;
		if(n&1){
//			cout << vals[i] << '\n';
//			cout << lo << ' ' << md << ' ' << hi << endl;
			if(lo<(n+1)/2&&lo+md>=(n+1)/2){
//				cout <<"A " << i << endl;
			   	ans+=cnt;
			}
		}else{
			if(lo<n/2&&lo+md>=n/2){
				if(lol==-1){
				   	lol=vals[i];hil=vals[i]-cnt+1;
				}
				else hil=vals[i]-cnt+1;
			}
			if(lo<=n/2&&lo+md>=n/2+1){
				if(lor==-1){
				   	lor=vals[i];hir=vals[i]-cnt+1;
				}
				else hir=vals[i]-cnt+1;
			}
		}	
	}
	if(!(n&1)){
		ans=(hir+hil-lol-lor+1);
	}
	cout << ans;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); 
	int T=1;
//	cin >> T;
	forse(c,1,T+1){
	//	cout << "Case #" << cid << ": ";
		solve();
	}
}


Measured memory_bytes: 13188