import sys

input = sys.stdin.readline

N = int(eval(input()))

keta = len(str(N))

if keta == 1:

    print(N)

    sys.exit()

ans = {}

for i in [1,2,3,4,5,6,7,8,9]:

    for j in [1,2,3,4,5,6,7,8,9]:

        ans[(i, j)] = 0

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

    maxdigit = int(str(i)[0])

    mindigit = int(str(i)[-1])

    if mindigit != 0:

        ans[(maxdigit, mindigit)] += 1

cnt = 0

for i in range(1, 10):

    for j in range(1, 10):

        if i == j:

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

        else:

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

            ans[(i, j)] = 0

            ans[(j, i)] = 0

print(cnt)



        



    
import sys

input = sys.stdin.readline



n = int(eval(input()))



from collections import defaultdict



d = defaultdict(int) # d[(a, b)] : 先頭a, 末尾b



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

    i_str = str(i)

    d[(i_str[0], i_str[-1])] += 1



ans = 0



for i in range(1, 10):

    for j in range(10):

        ans += d[(str(i), str(j))] * d[(str(j), str(i))]



print(ans)
import sys

input = sys.stdin.readline
N = int(eval(input()))
keta = len(str(N))
if keta == 1:
    print(N)
    sys.exit()
ans = {}
for i in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
    for j in [1, 2, 3, 4, 5, 6, 7, 8, 9]:
        ans[(i, j)] = 0
for i in range(1, N + 1):
    maxdigit = int(str(i)[0])
    mindigit = int(str(i)[-1])
    if mindigit != 0:
        ans[(maxdigit, mindigit)] += 1
cnt = 0
for i in range(1, 10):
    for j in range(1, 10):
        if i == j:
            cnt += ans[(i, i)] ** 2
        else:
            cnt += ans[(i, j)] * ans[(j, i)] * 2
            ans[(i, j)] = 0
            ans[(j, i)] = 0
print(cnt)

import sys

input = sys.stdin.readline
n = int(eval(input()))
from collections import defaultdict

d = defaultdict(int)  # d[(a, b)] : 先頭a, 末尾b
for i in range(1, n + 1):
    i_str = str(i)
    d[(i_str[0], i_str[-1])] += 1
ans = 0
for i in range(1, 10):
    for j in range(10):
        ans += d[(str(i), str(j))] * d[(str(j), str(i))]
print(ans)

-N = int(eval(input())) -keta = len(str(N)) -if keta == 1: -    print(N) -    sys.exit() -ans = {} -for i in [1, 2, 3, 4, 5, 6, 7, 8, 9]: -    for j in [1, 2, 3, 4, 5, 6, 7, 8, 9]: -        ans[(i, j)] = 0 -for i in range(1, N + 1): -    maxdigit = int(str(i)[0]) -    mindigit = int(str(i)[-1]) -    if mindigit != 0: -        ans[(maxdigit, mindigit)] += 1 -cnt = 0 +n = int(eval(input())) +from collections import defaultdict + +d = defaultdict(int)  # d[(a, b)] : 先頭a, 末尾b +for i in range(1, n + 1): +    i_str = str(i) +    d[(i_str[0], i_str[-1])] += 1 +ans = 0 -    for j in range(1, 10): -        if i == j: -            cnt += ans[(i, i)] ** 2 -        else: -            cnt += ans[(i, j)] * ans[(j, i)] * 2 -            ans[(i, j)] = 0 -            ans[(j, i)] = 0 -print(cnt) +    for j in range(10): +        ans += d[(str(i), str(j))] * d[(str(j), str(i))] +print(ans)