'use strict'

function main(s) {

  const seqs= s.split('\n').slice(1, -1).map(el => el.split(' ').map(num => Number(num)));

  const isSeated = Array(100001).fill(0);

  for (const seq of seqs) {
    for (let i = seq[0]; i <= seq[1]; i++) {
      isSeated[i] = 1;
    }
  }

  const ans = isSeated.filter(num => (num === 1)).length;
  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
