fun main(args: Array<String>) {
    sumitrust2019d()
}

fun sumitrust2019d() {
    val n = readLine()!!.toInt()
    val s = readLine()!!


    val set = mutableSetOf<String>()

    for (l in 0..9) {
        for (m in 0..9) {
            for (r in 0..9) {
                val left = s.indexOfFirst { it.toString().toInt() == l }
                val right = s.indexOfLast { it.toString().toInt() == r }
                if (left == -1 || right == -1) continue
                
                val between = s.slice(left + 1..right - 1)
                if (between.contains(m.toString().toCharArray()[0])) {
                    set.add(l.toString() + m.toString() + r.toString())
                }
            }
        }
    }

    println(set.size)
}
