import itertools

N = int(eval(input()))

Nketa = len(str(N))



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





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

    mae = int(str(p)[0])

    ato = int(str(p)[-1])

    range_count[mae][ato] += 1



    



count = 0

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

    a_mae = int(str(j)[0])

    a_ato = int(str(j)[-1])

    

    b_mae = a_ato

    b_ato = a_mae

    

    if b_mae == 0:

        continue

    else:

        count += range_count[b_mae][b_ato]

print(count)

  
n = int(eval(input()))



all_count = 0

options = [str(i) for i in range(10)]



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



for i in range(n+1):

    checking = str(i)

    maeato[int(checking[0])][int(checking[-1])]+=1

all_count = 0

for i in range(1,10):

    for j in range(1,10):

        for k in range(1,10):

            for p in range(1,10):

                if i == p and j == k:

                    all_count+=maeato[i][j]*maeato[k][p]

print(all_count)
import itertools

N = int(eval(input()))
Nketa = len(str(N))
range_count = [[0 for j in range(10)] for i in range(10)]
for p in range(1, N + 1):
    mae = int(str(p)[0])
    ato = int(str(p)[-1])
    range_count[mae][ato] += 1
count = 0
for j in range(1, N + 1):
    a_mae = int(str(j)[0])
    a_ato = int(str(j)[-1])
    b_mae = a_ato
    b_ato = a_mae
    if b_mae == 0:
        continue
    else:
        count += range_count[b_mae][b_ato]
print(count)

n = int(eval(input()))
all_count = 0
options = [str(i) for i in range(10)]
maeato = [[0 for i in range(10)] for j in range(10)]
for i in range(n + 1):
    checking = str(i)
    maeato[int(checking[0])][int(checking[-1])] += 1
all_count = 0
for i in range(1, 10):
    for j in range(1, 10):
        for k in range(1, 10):
            for p in range(1, 10):
                if i == p and j == k:
                    all_count += maeato[i][j] * maeato[k][p]
print(all_count)

-import itertools - -N = int(eval(input())) -Nketa = len(str(N)) -range_count = [[0 for j in range(10)] for i in range(10)] -for p in range(1, N + 1): -    mae = int(str(p)[0]) -    ato = int(str(p)[-1]) -    range_count[mae][ato] += 1 -count = 0 -for j in range(1, N + 1): -    a_mae = int(str(j)[0]) -    a_ato = int(str(j)[-1]) -    b_mae = a_ato -    b_ato = a_mae -    if b_mae == 0: -        continue -    else: -        count += range_count[b_mae][b_ato] -print(count) +n = int(eval(input())) +all_count = 0 +options = [str(i) for i in range(10)] +maeato = [[0 for i in range(10)] for j in range(10)] +for i in range(n + 1): +    checking = str(i) +    maeato[int(checking[0])][int(checking[-1])] += 1 +all_count = 0 +for i in range(1, 10): +    for j in range(1, 10): +        for k in range(1, 10): +            for p in range(1, 10): +                if i == p and j == k: +                    all_count += maeato[i][j] * maeato[k][p] +print(all_count)