let id x = x
let n = Scanf.scanf "%d\n" id
let array = Array.init n (fun _ -> Scanf.scanf "%d %d\n" (fun a b -> (a,b)))
let list = Array.to_list array

let rec func l =
  match l with
  | [] -> 0
  | (a,b) :: rest -> (b-a+1) + func rest
  
let ans = func list
  
let () =
  Printf.printf "%d\n" ans