N = int(eval(input()))

mem = [[0]*10 for i in range(10)]



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

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

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

    mem[a][b] += 1



ans = 0

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

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

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

    ans += mem[b][a]

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



d = [[0]*10 for i in range(10)]

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

    s = str(n)

    d[int(s[0])][int(s[-1])] += 1

ans = 0

for i in range(10):

    for j in range(10):

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

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

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

-mem = [[0] * 10 for i in range(10)] -for i in range(1, N + 1): -    a = int(str(i)[0]) -    b = int(str(i)[-1]) -    mem[a][b] += 1 +d = [[0] * 10 for i in range(10)] +for n in range(1, N + 1): +    s = str(n) +    d[int(s[0])][int(s[-1])] += 1 -for i in range(1, N + 1): -    a = int(str(i)[0]) -    b = int(str(i)[-1]) -    ans += mem[b][a] +for i in range(10): +    for j in range(10): +        ans += d[i][j] * d[j][i]