n = int(eval(input()))



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

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

    s = str(i)

    x = int(s[0])

    y = int(s[-1])

    dp[x][y] += 1



ans = 0

for i in range(1, 10):

    for j in range(1, 10):

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



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



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

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

    s = str(i)

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



ans = 0

for i in range(10):

    for j in range(10):

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

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

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

-    x = int(s[0]) -    y = int(s[-1]) -    dp[x][y] += 1 +    dp[int(s[0])][int(s[-1])] += 1 -for i in range(1, 10): -    for j in range(1, 10): +for i in range(10): +    for j in range(10):