import sys

from itertools import combinations, permutations



def solve():

    input = sys.stdin.readline

    N = int(eval(input()))

    S = eval(input())

    left = [set() for _ in range(N)]

    right = [set() for _ in range(N)]

    for i in range(N - 1):

        left[i+1] |= left[i] | {int(S[i])}

        right[N - i - 2] |= right[N - i - 1] | {int(S[N - i - 1])}

    canuse = set()

    for i in range(1, N - 1):

        for l in left[i]:

            for r in right[i]:

                canuse |= {str(l) + S[i] + str(r)}

    print((len(canuse)))



    return 0



if __name__ == "__main__":

    solve()
def solve():

    N = int(eval(input()))

    S = list(eval(input()))

    right = [set() for _ in range(N)]

    for i in reversed(list(range(N - 1))): right[i] = right[i + 1] | {S[i + 1]}

    left = {S[0]}

    PIN = set()

    for i in range(1, N - 1):

        for ln in left:

            for rn in right[i]:

                p = ln + S[i] + rn

                PIN |= {p}

        left |= {S[i]}

    print((len(PIN)))



    return 0



if __name__ == "__main__":

    solve()
import sys
from itertools import combinations, permutations


def solve():
    input = sys.stdin.readline
    N = int(eval(input()))
    S = eval(input())
    left = [set() for _ in range(N)]
    right = [set() for _ in range(N)]
    for i in range(N - 1):
        left[i + 1] |= left[i] | {int(S[i])}
        right[N - i - 2] |= right[N - i - 1] | {int(S[N - i - 1])}
    canuse = set()
    for i in range(1, N - 1):
        for l in left[i]:
            for r in right[i]:
                canuse |= {str(l) + S[i] + str(r)}
    print((len(canuse)))
    return 0


if __name__ == "__main__":
    solve()

def solve():
    N = int(eval(input()))
    S = list(eval(input()))
    right = [set() for _ in range(N)]
    for i in reversed(list(range(N - 1))):
        right[i] = right[i + 1] | {S[i + 1]}
    left = {S[0]}
    PIN = set()
    for i in range(1, N - 1):
        for ln in left:
            for rn in right[i]:
                p = ln + S[i] + rn
                PIN |= {p}
        left |= {S[i]}
    print((len(PIN)))
    return 0


if __name__ == "__main__":
    solve()

-import sys -from itertools import combinations, permutations - - -    input = sys.stdin.readline -    S = eval(input()) -    left = [set() for _ in range(N)] +    S = list(eval(input())) -    for i in range(N - 1): -        left[i + 1] |= left[i] | {int(S[i])} -        right[N - i - 2] |= right[N - i - 1] | {int(S[N - i - 1])} -    canuse = set() +    for i in reversed(list(range(N - 1))): +        right[i] = right[i + 1] | {S[i + 1]} +    left = {S[0]} +    PIN = set() -        for l in left[i]: -            for r in right[i]: -                canuse |= {str(l) + S[i] + str(r)} -    print((len(canuse))) +        for ln in left: +            for rn in right[i]: +                p = ln + S[i] + rn +                PIN |= {p} +        left |= {S[i]} +    print((len(PIN)))