def main():

    M = int(eval(input()))

    ans = 0

    dc_sum = 0

    for i in range(M):

        d, c = (int(i) for i in input().split())

        dc_sum += d*c

        ans += c

    if dc_sum % 9 == 0:

        print((ans - 1 + dc_sum//9 - 1))

    else:

        print((ans - 1 + dc_sum//9))





if __name__ == '__main__':

    main()

def main():

    import sys

    input = sys.stdin.buffer.readline

    M = int(eval(input()))

    ans = 0

    dc_sum = 0

    for i in range(M):

        d, c = (int(i) for i in input().split())

        dc_sum += d*c

        ans += c

    if dc_sum % 9 == 0:

        print((ans - 1 + dc_sum//9 - 1))

    else:

        print((ans - 1 + dc_sum//9))





if __name__ == '__main__':

    main()

def main():
    M = int(eval(input()))
    ans = 0
    dc_sum = 0
    for i in range(M):
        d, c = (int(i) for i in input().split())
        dc_sum += d * c
        ans += c
    if dc_sum % 9 == 0:
        print((ans - 1 + dc_sum // 9 - 1))
    else:
        print((ans - 1 + dc_sum // 9))


if __name__ == "__main__":
    main()

def main():
    import sys

    input = sys.stdin.buffer.readline
    M = int(eval(input()))
    ans = 0
    dc_sum = 0
    for i in range(M):
        d, c = (int(i) for i in input().split())
        dc_sum += d * c
        ans += c
    if dc_sum % 9 == 0:
        print((ans - 1 + dc_sum // 9 - 1))
    else:
        print((ans - 1 + dc_sum // 9))


if __name__ == "__main__":
    main()

+    import sys + +    input = sys.stdin.buffer.readline