from sys import stdin



n = int(stdin.readline().rstrip())



li = [[0 for i in range(10)]for j in range(10)]



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

    atama = int(str(k)[0])

    ushiro = int(str(k)[-1])

    li[atama][ushiro] += 1



point = 0



for l in range(1,10):

    for m in range(1,10):

        point += li[l][m]*li[m][l]

print(point)
from collections import defaultdict



n = int(eval(input()))

dic = defaultdict(int)



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

    s = str(i)

    dic[int(s[0]),int(s[-1])] += 1



point = 0



for i in range(1,10):

    for j in range(1,10):

        point += dic[i,j]*dic[j,i]



print(point)
from sys import stdin

n = int(stdin.readline().rstrip())
li = [[0 for i in range(10)] for j in range(10)]
for k in range(1, n + 1):
    atama = int(str(k)[0])
    ushiro = int(str(k)[-1])
    li[atama][ushiro] += 1
point = 0
for l in range(1, 10):
    for m in range(1, 10):
        point += li[l][m] * li[m][l]
print(point)

from collections import defaultdict

n = int(eval(input()))
dic = defaultdict(int)
for i in range(1, n + 1):
    s = str(i)
    dic[int(s[0]), int(s[-1])] += 1
point = 0
for i in range(1, 10):
    for j in range(1, 10):
        point += dic[i, j] * dic[j, i]
print(point)

-from sys import stdin +from collections import defaultdict -n = int(stdin.readline().rstrip()) -li = [[0 for i in range(10)] for j in range(10)] -for k in range(1, n + 1): -    atama = int(str(k)[0]) -    ushiro = int(str(k)[-1]) -    li[atama][ushiro] += 1 +n = int(eval(input())) +dic = defaultdict(int) +for i in range(1, n + 1): +    s = str(i) +    dic[int(s[0]), int(s[-1])] += 1 -for l in range(1, 10): -    for m in range(1, 10): -        point += li[l][m] * li[m][l] +for i in range(1, 10): +    for j in range(1, 10): +        point += dic[i, j] * dic[j, i]