n = int(eval(input()))

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



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

    s = str(i)

    f, l = s[0], s[-1]

    if "0" in [f, l]: continue

    table[int(f)-1][int(l)-1] += 1



ans = 0

for i in range(9):

    for j in range(9):

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



print(ans)

n = int(eval(input()))

t = [[0] * 10 for _ in range(10)]



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

    si = str(i)

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



ans = 0

for i in range(10):

    for j in range(10):

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



print(ans)

n = int(eval(input()))
table = [[0 for _ in range(9)] for _ in range(9)]
for i in range(1, n + 1):
    s = str(i)
    f, l = s[0], s[-1]
    if "0" in [f, l]:
        continue
    table[int(f) - 1][int(l) - 1] += 1
ans = 0
for i in range(9):
    for j in range(9):
        ans += table[i][j] * table[j][i]
print(ans)

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

-table = [[0 for _ in range(9)] for _ in range(9)] +t = [[0] * 10 for _ in range(10)] -    s = str(i) -    f, l = s[0], s[-1] -    if "0" in [f, l]: -        continue -    table[int(f) - 1][int(l) - 1] += 1 +    si = str(i) +    t[int(si[0])][int(si[-1])] += 1 -for i in range(9): -    for j in range(9): -        ans += table[i][j] * table[j][i] +for i in range(10): +    for j in range(10): +        ans += t[i][j] * t[j][i]