fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val pairs = 1.until(n + 1).map {
        val nn = it.toString().map { it.toInt() }
        val s = nn[0]
        val e = nn[nn.size - 1]
        Pair(s, e)
    }.groupBy { it }
    val memo = hashMapOf<Pair<Int, Int>, Int>()
    val count = pairs.keys.map {
        val p = Pair(Math.min(it.first, it.second), Math.max(it.first, it.second))
        memo[p] ?: run {
            val a = pairs[it]?.size ?: 0
            val b = pairs[Pair(it.second, it.first)]?.size ?: 0
            memo[p] = a * b
            a * b
        }
    }.sum()
    println(count)
}