N = int(eval(input()))

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



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

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

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

    cnt[f][l] += 1



ans = 0



for i in range(1, 10):

    for j in range(1, 10):

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



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

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



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

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

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

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

N = int(eval(input()))
cnt = [[0] * 10 for _ in range(10)]
for i in range(1, N + 1):
    f = int(str(i)[0])
    l = int(str(i)[-1])
    cnt[f][l] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)

-for i in range(1, 10): -    for j in range(1, 10): +for i in range(10): +    for j in range(10):