n = int(eval(input()))

cou = 0

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

  i = str(i)

  if i[0]!="0" and i[-1]!="0":

    if int(i[0])>int(i[-1]):

      cou +=  (10**(len(i)-1)-1)//9

    elif int(i[0])<int(i[-1]):

      cou += (10**(len(i)-2)-1)//9

  #print(i,cou)



cou *= 2

    

l = [0 for i in range(9)]

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

  i = str(i)

  if i[0]==i[-1]:

    l[int(i[0])-1] += 1

l1 = [i*i for i in l]

print((sum(l1)+cou))
n = int(eval(input()))

dp = [[0]*10 for i in range(10)]

su = 0

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

  a,b = str(i)[0],str(i)[-1]

  dp[int(a)-1][int(b)-1] += 1

for i in range(10):

  for j in range(10):

    su += dp[i][j]*dp[j][i]

print(su)
n = int(eval(input()))
cou = 0
for i in range(1, n + 1):
    i = str(i)
    if i[0] != "0" and i[-1] != "0":
        if int(i[0]) > int(i[-1]):
            cou += (10 ** (len(i) - 1) - 1) // 9
        elif int(i[0]) < int(i[-1]):
            cou += (10 ** (len(i) - 2) - 1) // 9
    # print(i,cou)
cou *= 2
l = [0 for i in range(9)]
for i in range(1, n + 1):
    i = str(i)
    if i[0] == i[-1]:
        l[int(i[0]) - 1] += 1
l1 = [i * i for i in l]
print((sum(l1) + cou))

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

-cou = 0 +dp = [[0] * 10 for i in range(10)] +su = 0 -    i = str(i) -    if i[0] != "0" and i[-1] != "0": -        if int(i[0]) > int(i[-1]): -            cou += (10 ** (len(i) - 1) - 1) // 9 -        elif int(i[0]) < int(i[-1]): -            cou += (10 ** (len(i) - 2) - 1) // 9 -    # print(i,cou) -cou *= 2 -l = [0 for i in range(9)] -for i in range(1, n + 1): -    i = str(i) -    if i[0] == i[-1]: -        l[int(i[0]) - 1] += 1 -l1 = [i * i for i in l] -print((sum(l1) + cou)) +    a, b = str(i)[0], str(i)[-1] +    dp[int(a) - 1][int(b) - 1] += 1 +for i in range(10): +    for j in range(10): +        su += dp[i][j] * dp[j][i] +print(su)