### 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])

        for num in lucky_nums:
            for i in range(10):
                for j in range(10):
                    if array_2d[i][j] == 1:
                        array_3d[i][j][num] = 1

            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()