output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: N = int(input())
  for i in range(6):
      if 10**i <= N < 10 ** (i + 1):
          a = i + 1
          break
  b = N // (10 ** (a - 1))
  m = 0
  if a >= 3:
      for j in range(a - 2):
          m += 10**j
  
  table = [[0 + m] * 9 for _ in range(9)]
  
  if a == 2:
      for i in range(0, 9):
          for j in range(0, 9):
              if (i + 1) * 10 + j <= N:
                  table[i][j] += 1
  
  
  if a >= 2:
      for i in range(0, 9):
          table[i][i] += 1
  else:
      for i in range(0, 9):
          if i + 1 <= N:
              table[i][i] += 1
  
  
  if a >= 3:
      for i in range(0, b - 1):
          for j in range(0, 9):
              table[i][j] += 10 ** (a - 2)
  
      for j in range(0, 9):
          if (N - (b * 10 ** (a - 1) + j + 1)) // 10 >= 1:
              table[b - 1][j] += (N - (b * 10 ** (a - 1) + j + 1)) // 10
  
  A = 0
  for i in range(0, 9):
      for j in range(i, 9):
          A += table[i][j] * table[j][i]
  
  B = 0
  for i in range(0, 9):
      B += table[i][i] * table[i][i]
  
  
  print((A - B) * 2 + B)
  
problem_description: Statement
  
  Given is a positive integer N.  
  Find the number of pairs (A, B) of positive integers not greater than N that
  satisfy the following condition:
  
    * When A and B are written in base ten without leading zeros, the last digit of A is equal to the first digit of B, and the first digit of A is equal to the last digit of B.
samples: [{"input": "25", "output": "17\n    \n\nThe following 17 pairs satisfy the condition: (1,1), (1,11), (2,2), (2,22),\n(3,3), (4,4), (5,5), (6,6), (7,7), (8,8), (9,9), (11,1), (11,11), (12,21),\n(21,12), (22,2), and (22,22).\n\n* * *"}, {"input": "1", "output": "1\n    \n\n* * *"}, {"input": "100", "output": "108\n    \n\n* * *"}, {"input": "2020", "output": "40812\n    \n\n* * *"}, {"input": "200000", "output": "400000008"}]