N = int(eval(input()))

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

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

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



ans = 0

for i in range(10):

    for j in range(10):

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

        

print(ans)

N = int(eval(input()))



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

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

    j = x % 10

    while x >= 10:

        x //= 10

    i = x % 10

    dp[i][j] += 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()))
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    cnt[int(str(i)[0])][int(str(i)[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

N = int(eval(input()))
dp = [[0] * 10 for _ in range(10)]
for x in range(1, N + 1):
    j = x % 10
    while x >= 10:
        x //= 10
    i = x % 10
    dp[i][j] += 1
ans = 0
for i in range(1, 10):
    for j in range(1, 10):
        ans += dp[i][j] * dp[j][i]
print(ans)

-cnt = [[0] * 10 for _ in range(10)] -for i in range(1, N + 1): -    cnt[int(str(i)[0])][int(str(i)[-1])] += 1 +dp = [[0] * 10 for _ in range(10)] +for x in range(1, N + 1): +    j = x % 10 +    while x >= 10: +        x //= 10 +    i = x % 10 +    dp[i][j] += 1 -for i in range(10): -    for j in range(10): -        ans += cnt[i][j] * cnt[j][i] +for i in range(1, 10): +    for j in range(1, 10): +        ans += dp[i][j] * dp[j][i]