from collections import defaultdict

n = eval(input())

first_n = n[0]

finish_n = n[-1]

digit = len(n)

cnt = defaultdict(lambda :0)



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

    temp = str(i)

    temp_tuple = (int(temp[0]), int(temp[-1]))

    cnt[temp_tuple] += 1



ans = 0

for i in range(1, 10):

    for j in range(1, 10):

        ans += cnt[(i, j)] * cnt[(j, i)]

print(ans)

#print(cnt)
n = int(eval(input()))

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

#hort[i][j] := i~j

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

    temp = str(i)

    if temp[0] == '0' or temp[-1] == '0':continue 

    hort[int(temp[0]) - 1][int(temp[-1]) - 1] += 1



res = 0

for i in range(9):

    for j in range(9):

        if i != j:

            temp = hort[i][j] * hort[j][i] * 2

        else:

            temp = hort[i][j] * (hort[i][j] - 1) + hort[i][j]

            #print(temp, i, j)

        hort[i][j] = 0

        res += temp



print(res)
from collections import defaultdict

n = eval(input())
first_n = n[0]
finish_n = n[-1]
digit = len(n)
cnt = defaultdict(lambda: 0)
for i in range(1, int(n) + 1):
    temp = str(i)
    temp_tuple = (int(temp[0]), int(temp[-1]))
    cnt[temp_tuple] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += cnt[(i, j)] * cnt[(j, i)]
print(ans)
# print(cnt)

n = int(eval(input()))
hort = [[0] * 9 for i in range(9)]
# hort[i][j] := i~j
for i in range(1, n + 1):
    temp = str(i)
    if temp[0] == "0" or temp[-1] == "0":
        continue
    hort[int(temp[0]) - 1][int(temp[-1]) - 1] += 1
res = 0
for i in range(9):
    for j in range(9):
        if i != j:
            temp = hort[i][j] * hort[j][i] * 2
        else:
            temp = hort[i][j] * (hort[i][j] - 1) + hort[i][j]
            # print(temp, i, j)
        hort[i][j] = 0
        res += temp
print(res)

-from collections import defaultdict - -n = eval(input()) -first_n = n[0] -finish_n = n[-1] -digit = len(n) -cnt = defaultdict(lambda: 0) -for i in range(1, int(n) + 1): +n = int(eval(input())) +hort = [[0] * 9 for i in range(9)] +# hort[i][j] := i~j +for i in range(1, n + 1): -    temp_tuple = (int(temp[0]), int(temp[-1])) -    cnt[temp_tuple] += 1 -ans = 0 -for i in range(1, 10): -    for j in range(1, 10): -        ans += cnt[(i, j)] * cnt[(j, i)] -print(ans) -# print(cnt) +    if temp[0] == "0" or temp[-1] == "0": +        continue +    hort[int(temp[0]) - 1][int(temp[-1]) - 1] += 1 +res = 0 +for i in range(9): +    for j in range(9): +        if i != j: +            temp = hort[i][j] * hort[j][i] * 2 +        else: +            temp = hort[i][j] * (hort[i][j] - 1) + hort[i][j] +            # print(temp, i, j) +        hort[i][j] = 0 +        res += temp +print(res)