N = int(eval(input()))

A, B = [], []

for _ in range(N):

    ai, bi = list(map(int, input().split()))

    A.append(ai)

    B.append(bi)

AB = sorted(list(zip(A, B)))



count = len(AB)



# 先頭

count += AB[0][0] - 1



for i in range(N - 1):

    # i と j の間に何人入れられるか

    if AB[i + 1][0] > AB[i][0] + 1:

        count += AB[i + 1][0] - AB[i][0] - 1



# 末尾 (0点以上なので)

count += AB[-1][1] - 0



print(count)
from sys import stdin, setrecursionlimit

from collections import Counter, deque, defaultdict

from math import floor, ceil

from bisect import bisect_left

from itertools import combinations

setrecursionlimit(100000)



INF = int(1e10)

MOD = int(1e9 + 7)



def main():

    from builtins import int, map

    N = int(eval(input()))

    AB = []

    for _ in range(N):

        ai, bi = list(map(int, input().split()))

        AB.append((ai, bi))

    AB = sorted(AB, key=lambda x: x[0])

    ans = AB[0][0] - 1

    for i in range(N - 1):

        diff = AB[i + 1][0] - AB[i][0]

        ans += diff

    ans += AB[-1][1] + 1

    print(ans)    



if __name__ == '__main__':

    main()

N = int(eval(input()))
A, B = [], []
for _ in range(N):
    ai, bi = list(map(int, input().split()))
    A.append(ai)
    B.append(bi)
AB = sorted(list(zip(A, B)))
count = len(AB)
# 先頭
count += AB[0][0] - 1
for i in range(N - 1):
    # i と j の間に何人入れられるか
    if AB[i + 1][0] > AB[i][0] + 1:
        count += AB[i + 1][0] - AB[i][0] - 1
# 末尾 (0点以上なので)
count += AB[-1][1] - 0
print(count)

from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations

setrecursionlimit(100000)
INF = int(1e10)
MOD = int(1e9 + 7)


def main():
    from builtins import int, map

    N = int(eval(input()))
    AB = []
    for _ in range(N):
        ai, bi = list(map(int, input().split()))
        AB.append((ai, bi))
    AB = sorted(AB, key=lambda x: x[0])
    ans = AB[0][0] - 1
    for i in range(N - 1):
        diff = AB[i + 1][0] - AB[i][0]
        ans += diff
    ans += AB[-1][1] + 1
    print(ans)


if __name__ == "__main__":
    main()

-N = int(eval(input())) -A, B = [], [] -for _ in range(N): -    ai, bi = list(map(int, input().split())) -    A.append(ai) -    B.append(bi) -AB = sorted(list(zip(A, B))) -count = len(AB) -# 先頭 -count += AB[0][0] - 1 -for i in range(N - 1): -    # i と j の間に何人入れられるか -    if AB[i + 1][0] > AB[i][0] + 1: -        count += AB[i + 1][0] - AB[i][0] - 1 -# 末尾 (0点以上なので) -count += AB[-1][1] - 0 -print(count) +from sys import stdin, setrecursionlimit +from collections import Counter, deque, defaultdict +from math import floor, ceil +from bisect import bisect_left +from itertools import combinations + +setrecursionlimit(100000) +INF = int(1e10) +MOD = int(1e9 + 7) + + +def main(): +    from builtins import int, map + +    N = int(eval(input())) +    AB = [] +    for _ in range(N): +        ai, bi = list(map(int, input().split())) +        AB.append((ai, bi)) +    AB = sorted(AB, key=lambda x: x[0]) +    ans = AB[0][0] - 1 +    for i in range(N - 1): +        diff = AB[i + 1][0] - AB[i][0] +        ans += diff +    ans += AB[-1][1] + 1 +    print(ans) + + +if __name__ == "__main__": +    main()