[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let rec f1 xs =
    let flag = Array.create 10 false
    let a = Array.init (Array.length xs) (fun _ -> null)
    for (i, j) in Seq.zip xs [0 .. 30000] do
        flag.[i] <- true
        a.[j] <- Array.copy flag
    a

[<EntryPoint>]
let main _ =
    let N = read int
    let S = (read string).ToCharArray() |> Array.map (string >> int)

    let r1 = f1 S
    let r2 = f1 (Array.rev S) |> Array.rev

    let ans = Array.create 1000 false
    for i in [1 .. N - 2] do
        let mid = S.[i]
        let ls = r1.[i - 1]
        let rs = r2.[i + 1]
        for l in [0 .. 9] do
            for r in [0 .. 9] do
                if ls.[l] && rs.[r] then
                    let k = l * 100 + mid * 10 + r
                    ans.[k] <- true

    Array.filter ((=) true) ans
    |> Array.length
    |> printfn "%i"

    0