import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val n = readInteger()
    val s = br.readLine()!!

    val charIndexList = List(10) { mutableListOf<Int>() }
    for ((i, c) in s.withIndex()) charIndexList[c - '0'].add(i)

    var ans = 0
    for (i in 0..9) {
        val firstIndex = charIndexList[i].firstOrNull() ?: continue

        for (j in 0..9) {
            var ngSecond = -1
            var okSecond = charIndexList[j].size
            while (okSecond - ngSecond > 1) {
                val mid = (ngSecond + okSecond) / 2
                if (charIndexList[j][mid] > firstIndex) okSecond = mid else ngSecond = mid
            }

            if (okSecond !in charIndexList[j].indices) continue

            val secondIndex = charIndexList[j][okSecond]
            for (k in 0..9) {
                var ngThird = -1
                var okThird = charIndexList[k].size
                while (okThird - ngThird > 1) {
                    val mid = (okThird + ngThird) / 2
                    if (charIndexList[k][mid] > secondIndex) okThird = mid else ngThird = mid
                }

                if (okThird in charIndexList[k].indices) ans++
            }
        }
    }
    out.println(ans)
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)
