import sys



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60





def main():

    M, *DC = list(map(int, read().split()))

    D = DC[::2]

    C = DC[1::2]



    total = sum(d * c for d, c in zip(D, C))

    ans = sum(C) - 1 + (total - 1) // 9

    print(ans)

    return





if __name__ == '__main__':

    main()

import sys



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60





def main():

    M, *DC = list(map(int, read().split()))



    total = digits = 0

    for d, c in zip(DC[::2], DC[1::2]):

        total += d * c

        digits += c



    ans = digits - 1 + (total - 1) // 9



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60


def main():
    M, *DC = list(map(int, read().split()))
    D = DC[::2]
    C = DC[1::2]
    total = sum(d * c for d, c in zip(D, C))
    ans = sum(C) - 1 + (total - 1) // 9
    print(ans)
    return


if __name__ == "__main__":
    main()

import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60


def main():
    M, *DC = list(map(int, read().split()))
    total = digits = 0
    for d, c in zip(DC[::2], DC[1::2]):
        total += d * c
        digits += c
    ans = digits - 1 + (total - 1) // 9
    print(ans)
    return


if __name__ == "__main__":
    main()

-    D = DC[::2] -    C = DC[1::2] -    total = sum(d * c for d, c in zip(D, C)) -    ans = sum(C) - 1 + (total - 1) // 9 +    total = digits = 0 +    for d, c in zip(DC[::2], DC[1::2]): +        total += d * c +        digits += c +    ans = digits - 1 + (total - 1) // 9