#!/usr/bin/env python3

import sys



def solve(N: int, S: str):

    def nx(S):

        res = [[N+1] * 10 for _ in range(N+1)]

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

            for j in range(10):

                res[i][j] = res[i+1][j]

            res[i][int(S[i])] = i

        return res

    dp = [[0] * 3 for _ in range(N+1)]

    dp[1] = [1, 0, 0]

    res = nx(S)

    for i in range(0, N+1):

        for j in range(10):

            if res[i][j] >= N: continue

            if res[0][j] == res[i][j]:

                dp[res[i][j]+1][0] = 1

            dp[res[i][j]+1][1] += dp[i][0]

            dp[res[i][j]+1][2] += dp[i][1]

    res = 0

    for i in range(N+1):

        res += dp[i][2]

    print(res)

    return





# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)

def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    S = next(tokens)  # type: int

    solve(N, S)



if __name__ == '__main__':

    main()

#!/usr/bin/env python3

import sys





def solve(N: int, S: str):

    counter = 0

    for i in range(1000):

        c = i % 10

        b = (i // 10) % 10

        a = (i // 100) % 10

        aa = S.find(str(a))

        if aa != -1 and aa < N - 2:

            bb = S[aa+1:].find(str(b))

            if bb != -1 and bb < N - 1:

                cc = S[aa+bb+2:].find(str(c))

                if cc != -1:

                    counter += 1

    print(counter)





def main():

    def iterate_tokens():

        for line in sys.stdin:

            for word in line.split():

                yield word

    tokens = iterate_tokens()

    N = int(next(tokens))  # type: int

    S = next(tokens)  # type: int

    solve(N, S)





if __name__ == '__main__':

    main()

#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    def nx(S):
        res = [[N + 1] * 10 for _ in range(N + 1)]
        for i in range(N - 1, -1, -1):
            for j in range(10):
                res[i][j] = res[i + 1][j]
            res[i][int(S[i])] = i
        return res

    dp = [[0] * 3 for _ in range(N + 1)]
    dp[1] = [1, 0, 0]
    res = nx(S)
    for i in range(0, N + 1):
        for j in range(10):
            if res[i][j] >= N:
                continue
            if res[0][j] == res[i][j]:
                dp[res[i][j] + 1][0] = 1
            dp[res[i][j] + 1][1] += dp[i][0]
            dp[res[i][j] + 1][2] += dp[i][1]
    res = 0
    for i in range(N + 1):
        res += dp[i][2]
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: int
    solve(N, S)


if __name__ == "__main__":
    main()

#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    counter = 0
    for i in range(1000):
        c = i % 10
        b = (i // 10) % 10
        a = (i // 100) % 10
        aa = S.find(str(a))
        if aa != -1 and aa < N - 2:
            bb = S[aa + 1 :].find(str(b))
            if bb != -1 and bb < N - 1:
                cc = S[aa + bb + 2 :].find(str(c))
                if cc != -1:
                    counter += 1
    print(counter)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: int
    solve(N, S)


if __name__ == "__main__":
    main()

-    def nx(S): -        res = [[N + 1] * 10 for _ in range(N + 1)] -        for i in range(N - 1, -1, -1): -            for j in range(10): -                res[i][j] = res[i + 1][j] -            res[i][int(S[i])] = i -        return res - -    dp = [[0] * 3 for _ in range(N + 1)] -    dp[1] = [1, 0, 0] -    res = nx(S) -    for i in range(0, N + 1): -        for j in range(10): -            if res[i][j] >= N: -                continue -            if res[0][j] == res[i][j]: -                dp[res[i][j] + 1][0] = 1 -            dp[res[i][j] + 1][1] += dp[i][0] -            dp[res[i][j] + 1][2] += dp[i][1] -    res = 0 -    for i in range(N + 1): -        res += dp[i][2] -    print(res) -    return +    counter = 0 +    for i in range(1000): +        c = i % 10 +        b = (i // 10) % 10 +        a = (i // 100) % 10 +        aa = S.find(str(a)) +        if aa != -1 and aa < N - 2: +            bb = S[aa + 1 :].find(str(b)) +            if bb != -1 and bb < N - 1: +                cc = S[aa + bb + 2 :].find(str(c)) +                if cc != -1: +                    counter += 1 +    print(counter) -# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)