val Int.topDigit: Int
  get() = this.toString()[0].toString().toInt()
val Int.bottomDigit: Int
  get() = this % 10

fun main(args: Array<String>) {
  val N = readInt()

  // N が 2 桁までは定義通り
  if (N < 100) {
    var cnt = 0
    for (A in 1..N) {
      for (B in 1..N) {
        if (A.topDigit == B.bottomDigit && B.topDigit == A.bottomDigit) cnt++
      }
    }
    println(cnt)
    return
  }

  // N が 3 桁以上は工夫する
  val NStr = N.toString()
  val NCenterNum = NStr.substring(1 until NStr.length - 1).let { if (it.isEmpty()) 0 else it.toLong() }
  val NTopDigit = N.topDigit
  val NBtmDigit = N.bottomDigit

  // 戻り値: 特定の A に対する B のパターン数
  fun f(A: Int): Long {
    val AStr = A.toString()
    val topDigit = A.topDigit
    val btmDigit = A.bottomDigit

    if (btmDigit == 0) return 0L

    var cnt = 0L
    // B が 1 桁
    if (topDigit == btmDigit) cnt++
    // B が 中間桁
    var d = 1
    repeat(NStr.length - 2) {
      cnt += d
      d *= 10
    }
    // B が 最大桁
    if (btmDigit > NTopDigit) return cnt
    if (btmDigit < NTopDigit) return cnt + d
    if (topDigit > NBtmDigit) return cnt + NCenterNum
    return cnt + NCenterNum + 1
  }

  var sum = 0L
  for (n in 1..N) {
//    println("$n, ${f(n)}")
    sum += f(n)
  }
  println(sum)
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }
