import java.io.{BufferedReader, InputStreamReader}

import scala.collection.mutable

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val n = in.readLine().toInt
    val s = in.readLine()

    val cs = s.toCharArray

    val thirdChars = new Array[Set[Char]](n)

    thirdChars(n - 1) = Set(cs(n - 1))
    for {
      i <- (n - 2) to 2 by -1
    } {
      thirdChars(i) = thirdChars(i+1) + cs(i)
    }


    val pins = new mutable.HashSet[String]

    for {
      i <- 0 until (n - 2)
      j <- i+1 until (n - 1)
    } {
      val base = "" + cs(i) + cs(j)
      thirdChars(j+1).foreach { thirdChar =>
        pins += base + thirdChar
      }
    }

    System.out.println(
      pins.size
    )
  }
}
