object Main {
  def main(args: Array[String]): Unit = {
    val num = io.StdIn.readInt()
    var first_last_num_pair: Map[( Int, Int ), Int ] = Map.empty
    (1 to num).foreach { i =>
      val pair = pairFirstAndLast( i )
      if( first_last_num_pair.contains( pair ) ) first_last_num_pair = first_last_num_pair + ( pair -> ( first_last_num_pair( pair ) + 1 ) )
      else                                       first_last_num_pair = first_last_num_pair + ( pair -> 1 )
    }

    var ans = 0
    ( 1 to num ).foreach{ i =>
      val pair = pairFirstAndLast( i )
      val change_pair = ( pair._2, pair._1 )
      if( first_last_num_pair.contains( change_pair ) ) ans += first_last_num_pair( change_pair )
    }
    println( ans )
  }

    def pairFirstAndLast( num: Int ): ( Int, Int ) = {
      val num_str   = num.toString
      val first_num = num_str(0).toInt - 48
      val last_num  = num_str( num_str.length - 1 ).toInt - 48

      return ( first_num, last_num )
    }
}