from collections import defaultdict



d1 = defaultdict(int)

d2 = defaultdict(int)



n = int(eval(input()))



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

    si = str(i)

    f = si[0]

    l = si[-1]

    if f == l:

        d1[(f,l)]+=1

    else:

        d2[(f,l)]+=1



ans = 0

for v in list(d1.values()):

    if v == 1:

        ans += 1

    else:

        ans += v**2



for v in list(d2.keys()):

    ans += d2[v]*d2[(v[1],v[0])]*2

    d2[v] = 0



print(ans)
c = [[0]*10 for _ in range(10)]



n = int(eval(input()))



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

    si = str(i)

    c[int(si[0])][int(si[-1])] += 1



ans = 0

for i in range(10):

    for j in range(10):

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



print(ans)
from collections import defaultdict

d1 = defaultdict(int)
d2 = defaultdict(int)
n = int(eval(input()))
for i in range(1, n + 1):
    si = str(i)
    f = si[0]
    l = si[-1]
    if f == l:
        d1[(f, l)] += 1
    else:
        d2[(f, l)] += 1
ans = 0
for v in list(d1.values()):
    if v == 1:
        ans += 1
    else:
        ans += v**2
for v in list(d2.keys()):
    ans += d2[v] * d2[(v[1], v[0])] * 2
    d2[v] = 0
print(ans)

c = [[0] * 10 for _ in range(10)]
n = int(eval(input()))
for i in range(1, n + 1):
    si = str(i)
    c[int(si[0])][int(si[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)

-from collections import defaultdict - -d1 = defaultdict(int) -d2 = defaultdict(int) +c = [[0] * 10 for _ in range(10)] -    f = si[0] -    l = si[-1] -    if f == l: -        d1[(f, l)] += 1 -    else: -        d2[(f, l)] += 1 +    c[int(si[0])][int(si[-1])] += 1 -for v in list(d1.values()): -    if v == 1: -        ans += 1 -    else: -        ans += v**2 -for v in list(d2.keys()): -    ans += d2[v] * d2[(v[1], v[0])] * 2 -    d2[v] = 0 +for i in range(10): +    for j in range(10): +        ans += c[i][j] * c[j][i]