n = int(eval(input()))

letters_mapping = {num: {num2:[] for num2 in range(10)} for num in range(10)}



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

    first_letter = str(num)[0]

    last_letter = str(num)[-1]

    letters_mapping[int(first_letter)][int(last_letter)].append(num)



count = 0

for i, v in list(letters_mapping.items()):

    for j, x in list(letters_mapping[i].items()):

        for num in letters_mapping[i][j]:

            count += len(letters_mapping[j][i])

            

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

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

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

    s = str(i)

    if s[-1] != '0':

        a[int(s[0])][int(s[-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()))
letters_mapping = {num: {num2: [] for num2 in range(10)} for num in range(10)}
for num in range(1, n + 1):
    first_letter = str(num)[0]
    last_letter = str(num)[-1]
    letters_mapping[int(first_letter)][int(last_letter)].append(num)
count = 0
for i, v in list(letters_mapping.items()):
    for j, x in list(letters_mapping[i].items()):
        for num in letters_mapping[i][j]:
            count += len(letters_mapping[j][i])
print(count)

n = int(eval(input()))
a = [[0 for i in range(10)] for j in range(10)]
for i in range(1, n + 1):
    s = str(i)
    if s[-1] != "0":
        a[int(s[0])][int(s[-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)

-letters_mapping = {num: {num2: [] for num2 in range(10)} for num in range(10)} -for num in range(1, n + 1): -    first_letter = str(num)[0] -    last_letter = str(num)[-1] -    letters_mapping[int(first_letter)][int(last_letter)].append(num) -count = 0 -for i, v in list(letters_mapping.items()): -    for j, x in list(letters_mapping[i].items()): -        for num in letters_mapping[i][j]: -            count += len(letters_mapping[j][i]) -print(count) +a = [[0 for i in range(10)] for j in range(10)] +for i in range(1, n + 1): +    s = str(i) +    if s[-1] != "0": +        a[int(s[0])][int(s[-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)