#include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); long long N; cin >> N; map L; map> R; for(long long i=0; i> l >> r; L[l-N]++; R[r-1]++; } long long maxl = -1e9,minr = 2e9; for(auto [k,v] : L){ if(v >= 2) L[k+1] += v-1; if(v) maxl = max(maxl,k); } for(auto [k,v] : R){ if(v >= 2) R[k-1] += v-1; if(v) minr = min(minr,k); } cout << max(0LL,minr-maxl+1) << endl; }