fun main(args: Array<String>) = p6()

fun p6() {
    val n = readLine()!!.toInt()
    val s = readLine()!!.map { it.toString() }

    val indexOfFirsts = (0..9).map { i -> s.indexOfFirst { it == i.toString() } }
    val indexOfLasts = (0..9).map { i -> s.indexOfLast { it == i.toString() } }
    val set = mutableSetOf<String>()
    var answer = 0

    for (leftNumber in 0..9) for (middleNumber in 0..9) for (rightNumber in 0..9) {
        val leftIndex = indexOfFirsts[leftNumber]
        val rightIndex = indexOfLasts[rightNumber]
        if (leftIndex in s.indices && rightIndex in s.indices && leftIndex + 1 < rightIndex) {
            if (s.slice(leftIndex + 1..rightIndex - 1).contains(middleNumber.toString()))
                answer++
        }
    }

    println(answer)
}
