n = int(eval(input()))

book = [[0] * 9 for i in range(9)]



ans = 0



for i in range(1, n+1) :

    reverse = 0

    tmp = i

    time = 0

    flag = False

    end = -1

    while(tmp!=0) :

        remind = tmp % 10

        if time == 0 :

            if remind == 0 :

                flag = True

                break

            pre = remind

        tmp = tmp // 10

        time += 1

    if flag == True :

        continue

    if remind != 0 :

        book[remind-1][pre-1] += 1



for i in range(9) :

    for j in range(i, 9) :

        if i == j :

            ans += book[i][j] * book[j][i]

            #print('=', i, j, book[i][j] * book[j][i])

            continue

        if book[i][j] != 0 and book[j][i] != 0 :

            ans += book[i][j] * book[j][i] * 2

            #print('!', i, j, book[i][j] * book[j][i] * 2)



#for i in range(9) :

#    print(book[i])



print(ans)

n = int(eval(input()))

book = [[0] * 9 for i in range(9)]



ans = 0



for i in range(1, n+1) :

    pre = int(str(i)[0])

    end = int(str(i)[-1])



    if end != 0 :

        book[pre-1][end-1] += 1



for i in range(9) :

    for j in range(i, 9) :

        if i == j :

            ans += book[i][j] * book[j][i]

            #print('=', i, j, book[i][j] * book[j][i])

            continue

        if book[i][j] != 0 and book[j][i] != 0 :

            ans += book[i][j] * book[j][i] * 2

            #print('!', i, j, book[i][j] * book[j][i] * 2)



#for i in range(9) :

#    print(book[i])



print(ans)

n = int(eval(input()))
book = [[0] * 9 for i in range(9)]
ans = 0
for i in range(1, n + 1):
    reverse = 0
    tmp = i
    time = 0
    flag = False
    end = -1
    while tmp != 0:
        remind = tmp % 10
        if time == 0:
            if remind == 0:
                flag = True
                break
            pre = remind
        tmp = tmp // 10
        time += 1
    if flag == True:
        continue
    if remind != 0:
        book[remind - 1][pre - 1] += 1
for i in range(9):
    for j in range(i, 9):
        if i == j:
            ans += book[i][j] * book[j][i]
            # print('=', i, j, book[i][j] * book[j][i])
            continue
        if book[i][j] != 0 and book[j][i] != 0:
            ans += book[i][j] * book[j][i] * 2
            # print('!', i, j, book[i][j] * book[j][i] * 2)
# for i in range(9) :
#    print(book[i])
print(ans)

n = int(eval(input()))
book = [[0] * 9 for i in range(9)]
ans = 0
for i in range(1, n + 1):
    pre = int(str(i)[0])
    end = int(str(i)[-1])
    if end != 0:
        book[pre - 1][end - 1] += 1
for i in range(9):
    for j in range(i, 9):
        if i == j:
            ans += book[i][j] * book[j][i]
            # print('=', i, j, book[i][j] * book[j][i])
            continue
        if book[i][j] != 0 and book[j][i] != 0:
            ans += book[i][j] * book[j][i] * 2
            # print('!', i, j, book[i][j] * book[j][i] * 2)
# for i in range(9) :
#    print(book[i])
print(ans)

-    reverse = 0 -    tmp = i -    time = 0 -    flag = False -    end = -1 -    while tmp != 0: -        remind = tmp % 10 -        if time == 0: -            if remind == 0: -                flag = True -                break -            pre = remind -        tmp = tmp // 10 -        time += 1 -    if flag == True: -        continue -    if remind != 0: -        book[remind - 1][pre - 1] += 1 +    pre = int(str(i)[0]) +    end = int(str(i)[-1]) +    if end != 0: +        book[pre - 1][end - 1] += 1