def solve():

    N = int(eval(input()))

    S = list(eval(input()))

    ans = 0



    i_tmp = []

    j_tmp = []

    for i in range(N-2):

        if S[i] in i_tmp:

            continue

        else:

            i_tmp.append(S[i])

            j_tmp.clear()

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

            if S[j] in j_tmp:

                continue

            else:

                j_tmp.append(S[j])

                ans += len(set(S[j+1:]))

    print(ans)





if __name__ == '__main__':

    solve()
def solve():

    N = int(eval(input()))

    S = eval(input())

    ans = 0



    for i in range(10):

        s1 = S.find(str(i), 0, -2)

        if s1 == -1:

            continue

        for j in range(10):

            s2 = S.find(str(j), s1+1, -1)

            if s2 == -1:

                continue

            ans += len(set(S[s2+1:]))

    print(ans)





if __name__ == '__main__':

    solve()
def solve():
    N = int(eval(input()))
    S = list(eval(input()))
    ans = 0
    i_tmp = []
    j_tmp = []
    for i in range(N - 2):
        if S[i] in i_tmp:
            continue
        else:
            i_tmp.append(S[i])
            j_tmp.clear()
        for j in range(i + 1, N - 1):
            if S[j] in j_tmp:
                continue
            else:
                j_tmp.append(S[j])
                ans += len(set(S[j + 1 :]))
    print(ans)


if __name__ == "__main__":
    solve()

def solve():
    N = int(eval(input()))
    S = eval(input())
    ans = 0
    for i in range(10):
        s1 = S.find(str(i), 0, -2)
        if s1 == -1:
            continue
        for j in range(10):
            s2 = S.find(str(j), s1 + 1, -1)
            if s2 == -1:
                continue
            ans += len(set(S[s2 + 1 :]))
    print(ans)


if __name__ == "__main__":
    solve()

-    S = list(eval(input())) +    S = eval(input()) -    i_tmp = [] -    j_tmp = [] -    for i in range(N - 2): -        if S[i] in i_tmp: +    for i in range(10): +        s1 = S.find(str(i), 0, -2) +        if s1 == -1: -        else: -            i_tmp.append(S[i]) -            j_tmp.clear() -        for j in range(i + 1, N - 1): -            if S[j] in j_tmp: +        for j in range(10): +            s2 = S.find(str(j), s1 + 1, -1) +            if s2 == -1: -            else: -                j_tmp.append(S[j]) -                ans += len(set(S[j + 1 :])) +            ans += len(set(S[s2 + 1 :]))