n = int(eval(input()))

S = eval(input())

ans = 0

for i in range(10):

    first_idx = S.find(str(i))

    if first_idx == -1:

        continue



    for j in range(10):

        second_idx = S.find(str(j), first_idx+1)

        if second_idx == -1:

            continue





        count = [0] * 10

        for k in range(second_idx+1, n):

            num = int(S[k])

            count[num] += 1



        for c in count:

            if c != 0:

                ans += 1



print(ans)
import sys

input = sys.stdin.readline





def main():

    n = int(eval(input()))

    S: str = eval(input())

    ans = 0

    for s1 in range(10):

        idx1 = S.find(str(s1))

        if idx1 == -1:

            continue



        for s2 in range(10):

            idx2 = S.find(str(s2), idx1+1)

            if idx2 == -1:

                continue



            for s3 in range(10):

                idx3 = S.find(str(s3), idx2+1)

                if idx3 >= 0:

                    ans += 1



    print(ans)





if __name__ == "__main__":

    main()

n = int(eval(input()))
S = eval(input())
ans = 0
for i in range(10):
    first_idx = S.find(str(i))
    if first_idx == -1:
        continue
    for j in range(10):
        second_idx = S.find(str(j), first_idx + 1)
        if second_idx == -1:
            continue
        count = [0] * 10
        for k in range(second_idx + 1, n):
            num = int(S[k])
            count[num] += 1
        for c in count:
            if c != 0:
                ans += 1
print(ans)

import sys

input = sys.stdin.readline


def main():
    n = int(eval(input()))
    S: str = eval(input())
    ans = 0
    for s1 in range(10):
        idx1 = S.find(str(s1))
        if idx1 == -1:
            continue
        for s2 in range(10):
            idx2 = S.find(str(s2), idx1 + 1)
            if idx2 == -1:
                continue
            for s3 in range(10):
                idx3 = S.find(str(s3), idx2 + 1)
                if idx3 >= 0:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()

-n = int(eval(input())) -S = eval(input()) -ans = 0 -for i in range(10): -    first_idx = S.find(str(i)) -    if first_idx == -1: -        continue -    for j in range(10): -        second_idx = S.find(str(j), first_idx + 1) -        if second_idx == -1: +import sys + +input = sys.stdin.readline + + +def main(): +    n = int(eval(input())) +    S: str = eval(input()) +    ans = 0 +    for s1 in range(10): +        idx1 = S.find(str(s1)) +        if idx1 == -1: -        count = [0] * 10 -        for k in range(second_idx + 1, n): -            num = int(S[k]) -            count[num] += 1 -        for c in count: -            if c != 0: -                ans += 1 -print(ans) +        for s2 in range(10): +            idx2 = S.find(str(s2), idx1 + 1) +            if idx2 == -1: +                continue +            for s3 in range(10): +                idx3 = S.find(str(s3), idx2 + 1) +                if idx3 >= 0: +                    ans += 1 +    print(ans) + + +if __name__ == "__main__": +    main()