import java.math.BigDecimal
import java.util.*
import kotlin.math.log10
import kotlin.math.max
import kotlin.math.min

data class Range(val from: Int, val to: Int)
class Bit(val size: Int) {
    private val array = IntArray(size){0}
    fun get(index: Int): Int {
        var position = index
        var result = 0
        while (position >= 0) {
            result += array[position]
            position -= position.inv() and (position + 1)
        }
        return result
    }
    fun add(index: Int, value: Int) {
        var position = index
        while (position < array.size) {
            array[position] += value
            position += position.inv() and (position + 1)
        }
    }
}
class ReverseBit(val bit: Bit) {
    fun get(index: Int): Int {
        return bit.get(bit.size - index - 1)
    }
    fun add(index: Int, value: Int) {
        return bit.add(bit.size - index - 1, value)
    }
}
fun forOdd(ranges: List<Range>): Int{
    val sortByFrom = ranges.sortedBy(Range::from)
    val mid = ranges.size shr 1
    val minValue = sortByFrom[mid].from
    val sortByTo = ranges.sortedBy(Range::to)
    val maxValue = sortByTo[mid].to
    return maxValue - minValue + 1
}
fun forEven(ranges: List<Range>): Int {
    val sortByFrom = ranges.sortedBy(Range::from)
    val sortByTo = ranges.sortedBy(Range::to)
    val mid = ranges.size shr 1
    val minLeft = sortByFrom[mid - 1].from
    val maxLeft = sortByTo[mid - 1].to
    val minRight = sortByFrom[mid].from
    val maxRight = sortByTo[mid].to
    return maxLeft + maxRight - minLeft - minRight + 1
}
fun forEven2(ranges: List<Range>): Int {
    val sortByFrom = ranges.sortedBy(Range::from)
    val queue = PriorityQueue<Int>()
    var firstLeft = Int.MAX_VALUE
    var lastLeft = 0
    var firstRight = Int.MAX_VALUE
    var lastRight = 0
    var higher = 0
    var lower = 0
    var prev = 1
    val mid = ranges.size shr 1
    for ((from, to) in sortByFrom) {
        while (queue.isNotEmpty() && queue.first() < from) {
            prev = queue.poll()
            ++lower
            if (mid in lower .. higher) {
                firstLeft = min(prev, firstLeft)
                lastLeft = max(prev, lastLeft)
            }
            if (mid + 1 in lower .. higher) {
                firstRight = min(prev, firstRight)
                lastRight = max(prev, lastRight)
            }
        }
        prev = from
        ++higher
        if (mid in lower .. higher) {
            firstLeft = min(prev, firstLeft)
            lastLeft = max(prev, lastLeft)
        }
        if (mid + 1 in lower .. higher) {
            firstRight = min(prev, firstRight)
            lastRight = max(prev, lastRight)
        }
        queue.add(to)
    }
    while (queue.isNotEmpty()) {
        prev = queue.poll()
        ++lower
        if (mid in lower .. higher) {
            firstLeft = min(prev, firstLeft)
            lastLeft = max(prev, lastLeft)
        }
        if (mid + 1 in lower .. higher) {
            firstRight = min(prev, firstRight)
            lastRight = max(prev, lastRight)
        }
    }
    return lastLeft + lastRight - firstLeft - firstRight + 1
}
fun main() {
    val n = readLine()!!.trim().toInt()
    val ranges = List(n){
        val (a, b) = readLine()!!.trim().split(' ').map(String::toInt)
        Range(a, b)
    }
    println(if ((n and 1) == 0) {
        forEven(ranges)
    }else {
        forOdd(ranges)
    })
}
