n=int(eval(input()))

lists=[[ [] for j in range(10)]for i in range(10)]

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

    a=str(i)

    lists[int(str(a[0]))][int(str(a[-1]))].append(i)

c=0

for i in range(1,10):

    for j in range(1,10):

        c+=len(lists[i][j])*len(lists[j][i])

print(c)        

n=int(eval(input()))

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

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

    a=str(i)

    lists[int(a[0])][int(a[-1])]+=1

c=0

for i in range(1,10):

    for j in range(1,10):

        c+=lists[i][j]*lists[j][i]

print(c)        



        
n = int(eval(input()))
lists = [[[] for j in range(10)] for i in range(10)]
for i in range(1, n + 1):
    a = str(i)
    lists[int(str(a[0]))][int(str(a[-1]))].append(i)
c = 0
for i in range(1, 10):
    for j in range(1, 10):
        c += len(lists[i][j]) * len(lists[j][i])
print(c)

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

-lists = [[[] for j in range(10)] for i in range(10)] +lists = [[0 for j in range(10)] for i in range(10)] -    lists[int(str(a[0]))][int(str(a[-1]))].append(i) +    lists[int(a[0])][int(a[-1])] += 1 -        c += len(lists[i][j]) * len(lists[j][i]) +        c += lists[i][j] * lists[j][i]