from collections import defaultdict

N = int(eval(input()))



cnt = defaultdict(int)



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

    cnt[(str(a)[0], str(a)[-1])] += 1



ans = 0

for head in range(1, 10):

    for tail in range(1, 10):

        ans += cnt[(str(head), str(tail))] * cnt[(str(tail), str(head))]



print(ans)
from collections import defaultdict



N = int(eval(input()))



cnt = defaultdict(int)

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

    i = str(i)

    l = i[0]

    r = i[-1]

    cnt[(l, r)] += 1

    cnt[(r, l)] += 0



ans = 0

for (l, r), c in list(cnt.items()):

    ans += cnt[(r, l)] * c



print(ans)

from collections import defaultdict

N = int(eval(input()))
cnt = defaultdict(int)
for a in range(1, N + 1):
    cnt[(str(a)[0], str(a)[-1])] += 1
ans = 0
for head in range(1, 10):
    for tail in range(1, 10):
        ans += cnt[(str(head), str(tail))] * cnt[(str(tail), str(head))]
print(ans)

from collections import defaultdict

N = int(eval(input()))
cnt = defaultdict(int)
for i in range(1, N + 1):
    i = str(i)
    l = i[0]
    r = i[-1]
    cnt[(l, r)] += 1
    cnt[(r, l)] += 0
ans = 0
for (l, r), c in list(cnt.items()):
    ans += cnt[(r, l)] * c
print(ans)

-for a in range(1, N + 1): -    cnt[(str(a)[0], str(a)[-1])] += 1 +for i in range(1, N + 1): +    i = str(i) +    l = i[0] +    r = i[-1] +    cnt[(l, r)] += 1 +    cnt[(r, l)] += 0 -for head in range(1, 10): -    for tail in range(1, 10): -        ans += cnt[(str(head), str(tail))] * cnt[(str(tail), str(head))] +for (l, r), c in list(cnt.items()): +    ans += cnt[(r, l)] * c