N = int(eval(input()))

mat = list()

for i in range(10):

    mat.append([0] * 10)



for i in range(N):

    A = int(str(i + 1)[0])

    B = int(str(i + 1)[-1])

    mat[A][B] += 1

ans = 0

for i in range(N):

    A = int(str(i + 1)[0])

    B = int(str(i + 1)[-1])

    ans += mat[B][A]

print(ans)

N = int(eval(input()))

mat = list()

for i in range(10):

    mat.append([0] * 10)



for i in range(N):

    A = int(str(i + 1)[0])

    B = int(str(i + 1)[-1])

    mat[A][B] += 1

ans = 0

for i in range(10):

    for j in range(10):

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

print(ans)

N = int(eval(input()))
mat = list()
for i in range(10):
    mat.append([0] * 10)
for i in range(N):
    A = int(str(i + 1)[0])
    B = int(str(i + 1)[-1])
    mat[A][B] += 1
ans = 0
for i in range(N):
    A = int(str(i + 1)[0])
    B = int(str(i + 1)[-1])
    ans += mat[B][A]
print(ans)

N = int(eval(input()))
mat = list()
for i in range(10):
    mat.append([0] * 10)
for i in range(N):
    A = int(str(i + 1)[0])
    B = int(str(i + 1)[-1])
    mat[A][B] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += mat[i][j] * mat[j][i]
print(ans)

-for i in range(N): -    A = int(str(i + 1)[0]) -    B = int(str(i + 1)[-1]) -    ans += mat[B][A] +for i in range(10): +    for j in range(10): +        ans += mat[i][j] * mat[j][i]