### BUGGY CODE ###

import glob
import numpy as np
import sys


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'smbc2019\\D'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'


class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        N = int(self.input_data())
        S = self.input_data()
        lucky_nums = [int(s) for s in S]

        array_1d = np.zeros([10])
        array_2d = np.zeros([10,10])
        array_3d = np.zeros([10,10,10])

        array_fin_1d = [False for i in range(10)]
        array_fin_2d = [[False for i in range(10)] for j in range(10)]

        for num in lucky_nums:

            if array_fin_1d[num]:
                continue
            fin_count_i = 0
            for i in range(10):
                if array_1d[i] == 0:
                    continue
                if array_fin_1d[i]:
                    fin_count_i += 1
                    continue

                if array_fin_2d[i][num]:
                    continue

                fin_count_j = 0
                for j in range(10):
                    if array_2d[i][j] == 1:
                        array_3d[i][j][num] = 1
                        fin_count_j += 1
                if fin_count_j == 10:
                    array_fin_2d[i][num] = True

            if fin_count_i == 10:
                array_fin_1d[num] = True

            for i in range(10):
                if array_1d[i] == 1:
                    array_2d[i][num] = 1

            array_1d[num] = 1

        result = array_3d.sum()

        print(str(int(result)))


solver = Solver(REL_PATH)
solver.exec_resolve()


### FIXED CODE ###

import glob
import numpy as np
import sys
import time


# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'smbc2019\\D'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'


class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):
        start_time = time.time()

        N = int(self.input_data())
        S = self.input_data()
        lucky_nums = [int(s) for s in S]

        array_first = [0 for i in range(10)]
        array_last =[0 for i in range(10)]

        for i in range(10):
            index = S.find(str(i))
            array_first[i] = index
            index = S.rfind(str(i))
            array_last[i] = index

        count = 0
        for i in range(10):
            if array_first[i] == -1:
                continue
            for j in range(10):
                if array_first[i]+1 >= array_last[j]:
                    continue
                for k in range(10):
                    if k in lucky_nums[array_first[i]+1:array_last[j]]:
                        count += 1

        print(str(count))

solver = Solver(REL_PATH)
solver.exec_resolve()