n=int(eval(input()))

A=[[0 for i in range(9)] for j in range(9)]



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

    if i%10!=0:

        num=str(i)

        A[int(num[0])-1][int(num[-1])-1] +=1



cnt=0

for i in range(9):

    for j in range(9):

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



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

A=[[0 for i in range(10)] for j in range(10)]



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

    num=str(i)

    A[int(num[0])][int(num[-1])] +=1



ans=0

for i in range(1,10):

    for j in range(1,10):

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

        

print(ans)
n = int(eval(input()))
A = [[0 for i in range(9)] for j in range(9)]
for i in range(1, n + 1):
    if i % 10 != 0:
        num = str(i)
        A[int(num[0]) - 1][int(num[-1]) - 1] += 1
cnt = 0
for i in range(9):
    for j in range(9):
        cnt += A[i][j] * A[j][i]
print(cnt)

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

-A = [[0 for i in range(9)] for j in range(9)] +A = [[0 for i in range(10)] for j in range(10)] -    if i % 10 != 0: -        num = str(i) -        A[int(num[0]) - 1][int(num[-1]) - 1] += 1 -cnt = 0 -for i in range(9): -    for j in range(9): -        cnt += A[i][j] * A[j][i] -print(cnt) +    num = str(i) +    A[int(num[0])][int(num[-1])] += 1 +ans = 0 +for i in range(1, 10): +    for j in range(1, 10): +        ans += A[i][j] * A[j][i] +print(ans)