N = int(eval(input()))



d = [[0]*9 for _ in range(9)]



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

    if i % 10 == 0:

        continue

    s = str(i)

    x = int(s[-1])

    y = int(s[0])

    d[x-1][y-1] += 1



ans = 0

for i in range(9):

    for j in range(9):

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

print(ans)

from collections import defaultdict

N = int(eval(input()))



d = defaultdict(int)

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

    s = str(i)

    f = int(s[0])

    b = int(s[-1])

    d[(f, b)] += 1



ans = 0

for a in range(1, 10):

    for b in range(1, 10):

        ans += d[(a, b)] * d[(b, a)]

print(ans)
N = int(eval(input()))
d = [[0] * 9 for _ in range(9)]
for i in range(1, N + 1):
    if i % 10 == 0:
        continue
    s = str(i)
    x = int(s[-1])
    y = int(s[0])
    d[x - 1][y - 1] += 1
ans = 0
for i in range(9):
    for j in range(9):
        ans += d[i][j] * d[j][i]
print(ans)

from collections import defaultdict

N = int(eval(input()))
d = defaultdict(int)
for i in range(1, N + 1):
    s = str(i)
    f = int(s[0])
    b = int(s[-1])
    d[(f, b)] += 1
ans = 0
for a in range(1, 10):
    for b in range(1, 10):
        ans += d[(a, b)] * d[(b, a)]
print(ans)

+from collections import defaultdict + -d = [[0] * 9 for _ in range(9)] +d = defaultdict(int) -    if i % 10 == 0: -        continue -    x = int(s[-1]) -    y = int(s[0]) -    d[x - 1][y - 1] += 1 +    f = int(s[0]) +    b = int(s[-1]) +    d[(f, b)] += 1 -for i in range(9): -    for j in range(9): -        ans += d[i][j] * d[j][i] +for a in range(1, 10): +    for b in range(1, 10): +        ans += d[(a, b)] * d[(b, a)]