Joisino is working as a receptionist at a theater.
The theater has 100000 seats, numbered from 1 to 100000.
According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).
How many people are sitting at the theater now?

-----Constraints-----
 - 1≤N≤1000
 - 1≤l_i≤r_i≤100000
 - No seat is occupied by more than one person.
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
l_1 r_1
:
l_N r_N

-----Output-----
Print the number of people sitting at the theater.

-----Sample Input-----
1
24 30

-----Sample Output-----
7

There are 7 people, sitting at Seat 24,25,26,27,28,29 and 30.

Difficulty: introductory

Starter code:

Solutions:
N = int(input())
ans = 0
for _ in range(N):
  a, b = map(int, input().split())
  ans += b - a + 1
print(ans)

N = int(input())
ans = 0
for _ in range(N):
    l, r = map(int, input().split())
    ans += r-l+1

print(ans)

with open(0) as f:
    N, *lr = map(int, f.read().split())
print(sum(lr[1::2])-sum(lr[::2])+N)

a=int(input())
b=[input().split() for i in range(a)]
c=0
for i in range(a):
  c=c+(int(b[i][1])-int(b[i][0]))
print(c+a)

N = int(input())
seat = 0
for i in range(N):
    l, r = map(int, input().split())
    seat += r - l + 1
print(seat)

N = int(input())
res = 0

for i in range(N):
    l, r = map(int,input().split())
    res += r - l + 1
    
print(res)

n = int(input())
seat = [0] * (10 ** 5 + 1)
for i in range(n):
    l, r = list(map(int, input().split()))
    seat[l - 1] += 1
    seat[r] -= 1

for i in range(1, 10 ** 5):
    seat[i] += seat[i - 1]

res = 0
for i in range(10 ** 5):
    if seat[i] == 1:
        res += 1
print(res)


print(sum([r-l+1 for l,r in [list(map(int,input().split())) for _ in range(int(input()))]]))

N = int(input())
ppl = 0
for i in range(N):
  tmp = input().split(" ")
  ppl += int(tmp[1]) - int(tmp[0]) + 1

print(ppl)

n = int(input())
ans  = 0
for i in range(n):
    a,b = map(int,input().split())
    ans += b-a+1
print(ans)

n=int(input())
ans = 0
for i in range(n):
    a,b=(int(x) for x in input().split())
    c = b-a+1
    ans += c

print(ans)

n = int(input())
ans = 0
for i in range(n):
    l, r = map(int, input().split())
    ans += r-l+1

print(ans)

N = int(input())

cnt = 0

for _ in range(N):
  l, r = map(int,input().split())
  cnt += r - l + 1
  
print(cnt)

n = int(input())
sum = 0
for _ in range(n):
    a, b = map(int, input().split())
    sum += b-a+1
print(sum)

N=int(input())
ans=0
for i in range(N):
  l,r=map(int,input().split())
  ans += r-l+1
print(ans)

n = int(input())
ans = 0
for _ in range(n):
    l,r = list(map(int, input().split()))
    ans += r - l + 1
print(ans)

def main():
    n = int(input())
    ans = 0
    for _ in range(n):
        a, b = list(map(int, input().split()))
        ans += b - a + 1
    print(ans)


def __starting_point():
    main()

__starting_point()

n = int(input())
li = [list(map(int,input().split())) for i in range(n)]
cnt = 0
for i in li:
    cnt += i[1] - i[0] +1
print(cnt)

N, *_LR = map(int, open(0).read().split())
LR = list(zip(*[map(int, iter(_LR))]*2))

ans = 0

for l,r in LR:
    ans += r - l + 1
    
print(ans)

n=int(input())
kei=0
for i in range(n):
    l,r=map(int,input().split())
    kei += r-l+1
print(kei)

ans=0
N=int(input())
for i in range(N):
  a,b=map(int,input().split())
  ans+=b-a+1
print(ans)

N = int(input())
ans = 0
for i in range(N):
    l,r = map(int,input().split())
    ans += r - l + 1
print(str(ans))

a=int(input())
ans=0
for i in range(a):
   x,y=map(int,input().split())
   ans+=y-x+1
print(ans)

N=int(input())
people=0
for i in range(N):
    l,r=list(map(int,input().split()))
    people+=r-l+1
print(people)


n = int(input())
res = 0
for i in range(n):
    r, l = list(map(int, input().split()))
    res += l - r + 1
print(res)


n = int(input())
ans = 0
for i in range(n):
    a, b = list(map(int, input().split()))
    ans += b - a + 1

print(ans)


n = int(input())
ans = 0
for i in range(n):
  l, r = map(int, input().split())
  ans += (r - l + 1)
print(ans)

n = int(input())
lr = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
    ans += (lr[i][1]-lr[i][0]+1)
print(ans)

N = int(input())
p = 0
for i in range(N):
  l, r = map(int,input().split())
  p += r-l+1
print(p)

n=int(input())
ans=0
for i in range(n):
  l,r=list(map(int,input().split()))
  ans+=r-l+1

print(ans)


# -*- coding: utf-8 -*-

n = int(input())
a = [0]*n
b = [0]*n
ans = 0

for i in range(n):
    a[i],b[i] = list(map(int, input().split()))

for i in range(n):
    ans += b[i] - a[i] + 1

print(ans)



n=int(input())

cnt=0

for i in range(n):
    l,r = map(int, input().split())
    cnt += r-l+1

print(cnt)

n = int(input())
l = [tuple(map(int, input().split())) for i in range(n)]

cnt = 0
for i in l:
    cnt += (i[1] - i[0] + 1)
print(cnt)


n=int(input())
ans=0
for i in range(n):
    l,r=list(map(int,input().split()))
    ans+=r-l+1
print(ans)


N = int(input())
lr = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in lr:
  ans += i[1] -i[0] + 1
print(ans)

N = int(input())
ans = 0

for _ in range(N):
  l, r = map(int, input().split())
  ans += r - l + 1

print(ans)

n=int(input())
hito=0
for i in range(n):
    l,r=map(int, input().split())
    hito+=r-l+1
print(hito)

#!/usr/bin/env python3

def main():
    n = int(input())
    ans = 0
    for i in range(n):
        l, r = list(map(int, input().split()))
        ans += r - l + 1
    print(ans)


def __starting_point():
    main()

__starting_point()

N=int(input())
l=[0]*N
r=[0]*N
sum=0
for i in range(N) :
  l[i],r[i]=map(int,input().split())
  sum+=r[i]-l[i]+1
print(sum)

# coding = SJIS

n = int(input())
men = []
for i in range(n):
    l, r = map(int, input().split())
    men.append([l, r])
ans = 0

for i in range(n):
    ans += men[i][1] - men[i][0] + 1

print(ans)

n = int(input())
ans = 0
for i in range(n):
    l,r = map(int,input().split())
    ans += (r-l+1)
print(ans)

N = int(input())
sum = 0
for i in range(N):
  l, r = map(int, input().split())
  sum += (r-l) + 1
  
print(sum)

# 入力
N=int(input())

sm=0

for i in range(N):
  l,r=map(int,input().split())
  sm+=r-l+1

# 出力
print(sm)

n = int(input())
p = 0
for i in range(n):
  l, r = map(int, input().split())
  p += r-l+1
 
print(p)

#https://atcoder.jp/contests/abc073/tasks/abc073_b
N = int(input())
ans = 0
for i in range(N):
    st,sp = map(int,input().split())
    ans += abs(sp-st+1)
print(ans)

N = int(input())
s = 0
for _ in range(N):
    a, b = map(int, input().split())
    s += b - a + 1
print(s)

N = int(input())
ans = 0
for _ in range(N):
  l,r = map(int,input().split())
  ans += r - l + 1
  
print(ans)

import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: list(map(int, sys.stdin.readline().split()))
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
li = np.zeros(200000)
for _ in range(n):
  l, r = rm()
  li[l:r+1] = 1
print((int(sum(li))))









n = int(input())
total = 0
for i in range(n):
    l, r = map(int,input().split())
    total += r - l + 1
print(total)

N = int(input())
ans =  0

for i in range(N):
    l,r = list(map(int, input().split()))
    ans += r - l + 1
print(ans)


#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]
#a = [int(input()) for _ in range(n)]


n = int(input())

ans = 0

for i in range(n):
    l, r = list(map(int, input().split()))
    ans += r - l + 1
print(ans)


n = int(input())
A = [tuple(map(int, input().split())) for _ in range(n)]

ans = 0
for l, r in A:
    ans += r - l + 1
print(ans)


# ABC073
N = int(input())
L_R = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for l, r in L_R:
    ans += r - l + 1
print(ans)


n = int(input())

num = 0

for i in range(n):
    l,r = map(int,input().split())
    num += (r - l + 1)
    
print(num)

IS = lambda: int(input())
IA = lambda: [int(x) for x in input().split()]
IM = lambda N: [IA() for _ in range(N)]

ans = 0
for l,r in IM(IS()):
    ans += r - l + 1
print(ans)

def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    data =[Input() for _ in range(n)]
    ans = 0
    for start, end in data:
        for _ in range(start, end+1):
            ans += 1
    print(ans)


main()

n = int(input())
ans = 0
for i in range(n):
  l,r = map(int,input().split())
  ans += r+1-l
print(ans)

N = int(input())
ans = 0
for i in range(N):
    l, r = list(map(int, input().split()))
    ans += r-l+1
print(ans)


n = int(input())
data = [input().split() for i in range(n)]
ans = 0
for i in range(n):
    ans += int(data[i][1]) - int(data[i][0]) + 1
print(ans)

n=int(input())
ans=0
for i in range(n):
    l,r=list(map(int,input().split()))
    ans+=r-l+1
print(ans)


n = int(input())
num = 0
for i in range(n):
    l, r = map(int, input().split())
    num += (r - l) + 1
print(num)

n = int(input())
flg = [0]*100000
for _ in range(n):
    l,r = list(map(int,input().split()))
    for i in range(l,r+1):
        flg[i-1] = 1
print((flg.count(1)))


N = int(input())

ans = 0

for i in range(N):
   L = input().split()
   ans += int(L[1]) - int(L[0]) + 1

print(ans)

n = int(input())
tmp = 0
num_person = []
for _ in range(n):
    l, r = map(int, input().split())
    tmp =  r-l+1
    num_person.append(tmp)

ans = 0
for i in num_person:
    ans += i

print(ans)

n = int(input())
ans = 0
for i in range(n):
  l, r = map(int, input().split())
  ans += r - l + 1
print(ans)

n = int(input())
ans = 0
for i in range(n):
    l, r = map(int, input().split())
    ans += r - l + 1
print(ans)

n = int(input())
seat = [0] * 10 ** 6
for i in range(n):
    l, r = list(map(int, input().split()))
    for j in range(l, r + 1):
        seat[j - 1] = 1

res = 0
for i in range(10 ** 6):
    if seat[i] == 1:
        res += 1
print(res)


N = int(input())
res = 0
for _ in range(N):
    l, r = list(map(int, input().split()))
    res += r - l + 1

print(res)


n=int(input())
count=0
for _ in range(n):
  l,r=map(int,input().split())
  count+=r-l+1
print(count)

N = int(input())
a = 0
for i in range(N):
  line = list(map(int,input().split()))
  a +=(line[-1]-line[0]+1)
print(a)

N = int(input())
ans = 0
for _ in range(N):
  l,r = map(int,input().split())
  ans += (r-l)+1
print(ans)

n = int(input())
a = 0
for _ in range(n):
    l, r = map(int, input().split())
    a += r - l + 1
print(a)

N=int(input())
ans=0
for i in range(N):
  l,r=map(int,input().split())
  ans += r-l+1
print(ans)

n =int(input())

total = 0
for i in range(n):
    a = list(map(int, input().split()))
    total += a[1] - a[0] + 1

print(total)

N=int(input())
ans=0
for i in range(N):
    L,R=map(int,input().split())
    ans+=R-L+1
print(ans)

n = int(input())
res = 0
for i in range(n):
  l, r = map(int, input().split())
  res += r - l + 1
print(res)

N=int(input())
ans=0
for _ in range(N):
  l, r=map(int, input().split())
  ans+=r-l+1
print(ans)

N = int (input ())
x = 0
for i in range (N):
  s,g = map (int, input ().split ())
  le = g-s+1
  x += le
print (x)

n = int(input())
cnt = 0
for i in range(n):
  l, r = [int(x) for x in input().split()]
  cnt+=r-l+1
print(cnt)

n = int(input())
ans = 0
for _ in range(n):
    l,r = map(int,input().split())
    ans += r-l
print(ans+n)

n = int(input())
l = [0] * n
r = [0] * n
for i in range(n):
    l[i],r[i] = map(int, input().split())
res = 0

for i in range(n):
  res += r[i]-l[i]+1

print(res)

N = int(input())
ans = 0
for _ in range(N):
    l, r = (int(x) for x in input().split())
    ans += r-l+1
print(ans)

a=int(input())
x = ""
y = 0
for i in range(a):
    x=input().split()
    y+=abs(int(x[0])-int(x[1]))+1
print(y)

N=int(input())
print(sum(r-l+1 for l,r in (map(int,input().split()) for _ in range(N))))

from typing import List


def answer(n: int, lrs: List[List[int]]) -> int:
    number_of_people_sitting = 0
    for lr in lrs:
        l, r = lr
        number_of_people_sitting += r - l + 1

    return number_of_people_sitting


def main():
    n = int(input())
    lrs = [map(int, input().split()) for _ in range(n)]
    print(answer(n, lrs))


def __starting_point():
    main()
__starting_point()

n = int(input())
c = 0
for i in range(n):
  l,r = map(int, input().split())
  c += r-l+1
print(c)

N=int(input())
ans=0
for _ in range(N):
    l,r=list(map(int,input().split()))
    ans+=r-l+1
print(ans)


N = int(input())

ans = 0

for _ in range(N):
    l,r = map(int, input().split())
    ans += r - l + 1

print(ans)

n = int(input())
num = 0
for i in range(n):
    l,r = map(int, input().split())
    num += (r-l+1)
print(num)

N = int(input())
l = [0] * N
r = [0] * N
for i in range(N):
    l[i], r[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
    ans += r[i] - (l[i] - 1)
print(ans)


n=int(input())
lr=[list(map(int,input().split())) for i in range(n)]
ans=0
for i in range(n):
  ans+=(lr[i][1]-lr[i][0]+1)
print(ans)

#
# abc073 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1
24 30"""
        output = """7"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """2
6 8
3 3"""
        output = """4"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    LR = [list(map(int, input().split())) for _ in range(N)]

    ans = 0
    for lr in LR:
        l, r = lr
        ans += r - l + 1

    print(ans)


def __starting_point():
    # unittest.main()
    resolve()

__starting_point()

n = int(input())
# seat = [0] * 10 ** 6
seat = [0] * 10 ** 5
for i in range(n):
    l, r = list(map(int, input().split()))
    for j in range(l, r + 1):
        seat[j - 1] = 1

res = 0
# for i in range(10 ** 6):
for i in range(10 ** 5):
    if seat[i] == 1:
        res += 1
print(res)


N = int(input())
cnt = 0
for _ in range(N):
    l, r = map(int, input().split())
    cnt += r - l + 1
print(cnt)

n = int(input())
ans = 0
for i in range(n):
  a, b = map(int, input().split())
  ans += (b - a + 1)
print(ans)

n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
ans = 0
for i in range(n):
    l, r = list(map(int, input().split()))
    ans += r-l+1
print(ans)


N = int(input())
sum = 0
for i in range(N):
  l, r = map(int, input().split())
  sum += r - l + 1
print(sum)

n = int(input())
res = 0
for i in range(n):
  a = [int(x) for x in input().split()]
  res += a[1] - a[0] + 1
print(res)