output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: N = int(input())
  total = 0
  for i in [idx + 1 for idx in range(N)]:
      a = int(str(i)[0])
      b = int(str(i)[-1])
      if b != 0:
          if a == b:
              if N < 10:
                  if a <= N:
                      total += 1
              elif N < 100:
                  total += 1
                  if a * 10 + a <= N:
                      total += 1
              elif N < 1000:
                  total += 1
                  total += 1
                  if a * 100 + 90 + a <= N:
                      total += 10
                  elif a * 100 + a >= N:
                      if N % 10 < a:
                          total += int(str(N)[1]) - 1
                      else:
                          total += int(str(N)[1])
              elif N < 10000:
                  total += 1
                  total += 1
                  total += 10
                  if a * 1000 + 990 + a <= N:
                      total += 100
                  elif a * 1000 + a >= N:
                      if N % 10 < a:
                          total += int(str(N)[1]) * 10 + int(str(N)[2]) - 1
                      else:
                          total += int(str(N)[1]) * 10 + int(str(N)[2])
              elif N < 100000:
                  total += 1
                  total += 1
                  total += 10
                  total += 100
                  if a * 10000 + 9990 + a <= N:
                      total += 1000
                  elif a * 10000 + a >= N:
                      if N % 10 < a:
                          total += (
                              int(str(N)[1]) * 100
                              + int(str(N)[2]) * 10
                              + int(str(N)[3])
                              - 1
                          )
                      else:
                          total += (
                              int(str(N)[1]) * 100 + int(str(N)[2]) * 10 + int(str(N)[3])
                          )
              elif N < 1000000:
                  total += 1
                  total += 1
                  total += 10
                  total += 100
                  total += 1000
                  if a * 100000 + 99990 + a <= N:
                      total += 10000
                  elif a * 100000 + a >= N:
                      if N % 10 < a:
                          total += (
                              int(str(N)[1]) * 1000
                              + int(str(N)[2]) * 100
                              + int(str(N)[3]) * 10
                              + int(str(N)[4])
                              - 1
                          )
                      else:
                          total += (
                              int(str(N)[1]) * 1000
                              + int(str(N)[2]) * 100
                              + int(str(N)[3]) * 10
                              + int(str(N)[4])
                          )
          else:
              if N < 100:
                  if b * 10 + a <= N:
                      if N % 10 < a:
                          total += int(str(N)[1]) - 1
                      else:
                          total += int(str(N)[1])
              elif N < 1000:
                  total += 1
                  if b * 100 + 90 + a <= N:
                      total += 10
                  elif b * 100 + a >= N:
                      if N % 10 < a:
                          total += int(str(N)[1]) * 10 + int(str(N)[2]) - 1
                      else:
                          total += int(str(N)[1]) * 10 + int(str(N)[2])
              elif N < 10000:
                  total += 1
                  total += 10
                  if b * 1000 + 990 + a <= N:
                      total += 100
                  elif b * 1000 + a >= N:
                      if N % 10 < a:
                          total += int(str(N)[1]) * 10 + int(str(N)[2]) - 1
                      else:
                          total += int(str(N)[1]) * 10 + int(str(N)[2])
              elif N < 100000:
                  total += 1
                  total += 10
                  total += 100
                  if b * 10000 + 9990 + a <= N:
                      total += 1000
                  elif b * 10000 + a >= N:
                      if N % 10 < a:
                          total += (
                              int(str(N)[1]) * 100
                              + int(str(N)[2]) * 10
                              + int(str(N)[3])
                              - 1
                          )
                      else:
                          total += (
                              int(str(N)[1]) * 100 + int(str(N)[2]) * 10 + int(str(N)[3])
                          )
              elif N < 1000000:
                  total += 1
                  total += 10
                  total += 100
                  total += 1000
                  if b * 100000 + 99990 + a <= N:
                      total += 10000
                  elif b * 100000 + a >= N:
                      total += (
                          int(str(N)[1]) * 1000
                          + int(str(N)[2]) * 100
                          + int(str(N)[3]) * 10
                          + int(str(N)[4])
                      )
  print(total)
  
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"}]