Option Strict On
Imports System.Collections.Generic
Module problemD

    Sub Main()
        Dim n As Integer = Integer.Parse(Console.ReadLine) - 1
        Dim sc() As Char = Console.ReadLine.ToCharArray()
        Dim s(n) As Integer        
        Dim ih, jh As New Dictionary(Of Integer, HashSet(Of Integer))
        Dim kh As New HashSet(Of Integer)
        Dim wi, wj, wk As Integer
        Dim i, j, k As Integer

        For i = 0 To n
    		s(i) = Convert.ToInt32(sc(i))
        Next

        For i = 0 To n - 2
            wi = s(i)
            If Not ih.ContainsKey(wi) Then ih.Add(wi, New HashSet(Of Integer))
            If ih(wi).Contains(-1) Then Continue For

            For j = i + 1 To n - 1
                wj = s(i) * 10 + s(j)
                If Not jh.ContainsKey(wj) Then jh.Add(wj, New HashSet(Of Integer))
                If jh(wj).Contains(-1) Then Continue For

                For k = j + 1 To n
                    wk = s(i) * 100 + s(j) * 10 + s(k)
                    If kh.Contains(wk) Then Continue For
                    kh.Add(wk)

                    jh(wj).Add(s(k))
                    If jh(wj).Count > 9 Then Exit For
                Next

                jh(wj).Add(-1)
                ih(wi).Add(s(j))
                If ih(wi).Count > 9 Then Exit For
            Next

            ih(wi).Add(-1)
            If ih.Count > 9 Then Exit For
        Next

        Console.Write(kh.Count.ToString)
    End Sub

End Module
