N = int(eval(input()))

count = [[0 for _ in range(9)] for _ in range(9)]

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

    if str(i)[0] != "0" and str(i)[-1] != "0":

        count[int(str(i)[0]) - 1][int(str(i)[-1]) - 1] += 1

ans = 0

for i in range(0, 9):

    for k in range(0, 9):

        ans += count[i][k] * count[k][i]

print(ans)
N = int(eval(input()))

nums = [0 for i in range(100)]

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

    i = str(i)

    nums[int(i[0] + i[-1])] += 1

ans = 0

for i in range(1, 10):

    for j in range(i, 10):

        i = str(i)

        j = str(j)

        if i != j:

            ans += nums[int(i + j)] * nums[int(j + i)] * 2

        else:

            n = nums[int(i + j)]

            ans += n * (n - 1)

            ans += n

print(ans)
N = int(eval(input()))
count = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, N + 1):
    if str(i)[0] != "0" and str(i)[-1] != "0":
        count[int(str(i)[0]) - 1][int(str(i)[-1]) - 1] += 1
ans = 0
for i in range(0, 9):
    for k in range(0, 9):
        ans += count[i][k] * count[k][i]
print(ans)

N = int(eval(input()))
nums = [0 for i in range(100)]
for i in range(1, N + 1):
    i = str(i)
    nums[int(i[0] + i[-1])] += 1
ans = 0
for i in range(1, 10):
    for j in range(i, 10):
        i = str(i)
        j = str(j)
        if i != j:
            ans += nums[int(i + j)] * nums[int(j + i)] * 2
        else:
            n = nums[int(i + j)]
            ans += n * (n - 1)
            ans += n
print(ans)

-count = [[0 for _ in range(9)] for _ in range(9)] +nums = [0 for i in range(100)] -    if str(i)[0] != "0" and str(i)[-1] != "0": -        count[int(str(i)[0]) - 1][int(str(i)[-1]) - 1] += 1 +    i = str(i) +    nums[int(i[0] + i[-1])] += 1 -for i in range(0, 9): -    for k in range(0, 9): -        ans += count[i][k] * count[k][i] +for i in range(1, 10): +    for j in range(i, 10): +        i = str(i) +        j = str(j) +        if i != j: +            ans += nums[int(i + j)] * nums[int(j + i)] * 2 +        else: +            n = nums[int(i + j)] +            ans += n * (n - 1) +            ans += n