module kkk
  sub main()
    
    dim ns as string = Console.ReadLine()
    dim n as integer = Integer.Parse(ns)
    dim le as integer = len(ns)
    dim al as integer
    dim ar as integer
    dim ans as integer
    dim le2 as integer
    dim i2 as string
    
    dim i as long
    
    for i = 1 to n
    al = left(i, 1)
    ar = right(i, 1)
    i2 = 1
    le2 = i2.length
    if al = ar then
      if le2 > 2 then
        ans = ans + 1 + 9 ^ (le2 - 2)
      else
        if le2 = 1 then
          ans = ans + 1
        else
        	ans = ans + 2
        end if
      end if
    else
      if le2 > 2 then
        ans = ans + 9 ^ (le2 - 2)
      else
        ans = ans + 1
      end if
    end if
  next
  
  console.writeline(ans)
  
end sub
end module
      
      
      