output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: """
  108345237845804
  498073591
  are an example match, because (1,4) and (4,1)
  each integer can be encoded as this kind of pair
  if there is also
  4768281
  then we have 2 matches so far, because the
  first matches with the second and third
  considering 1 and 11 and 111 and 1111 and 11111
  each are encoded as (1,1), so we get 9 matches from just these 5...
  solution :
  just count how many integers get encoded as a certain pair, then calculate
  the number of pairs that would be made from them
  eg if (1,4) = 10 and (4,1) = 5 then there are 5*10 = 50 pairs
  How many encodings? no leading zero, so also ending zero wont get a match,
  so 1 to 9 and 1 to 9, is 9*9=81 encodings
  """
  
  
  def handstand(N):
      # first count how many integers have a given encoding
      count_encoding = {(x, y): 0 for x in range(1, 10) for y in range(1, 10)}
      for i in range(1, N + 1):
          string_convert = str(i)
          start_val = int(string_convert[0])
          end_val = int(string_convert[-1])
          if end_val == 0:
              continue
          count_encoding[start_val, end_val] += 1
      # now count the encoding matches
      matches_count = 0
      for x in range(1, 10):
          for y in range(1, 10):
              matches_count += count_encoding[x, y] * count_encoding[y, x]
      return matches_count
  
  
  if __name__ == "__main__":
      test1 = "25"
      test2 = "1"
      test3 = "100"
      test4 = "2020"
      test5 = "200000"
      test6 = "16"
      test = test4
      # in_val = int(test)
      in_val = int(input())
      print(handstand(in_val))
  
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"}]