n = int(eval(input()))

s = list(map(int, eval(input())))





def is_Lucky(x):

    x = tuple(map(int, '{:03d}'.format(x)))

    idx = 0

    for c in s:

        if x[idx] == c:

            idx += 1

            if idx == 3:

                return True

    else:

        return False





ans = 0

for i in range(1000):

    if is_Lucky(i):

        ans += 1

print(ans)

import bisect

from collections import defaultdict

n = int(eval(input()))

s = eval(input())



cnt = defaultdict(list)

for i, c in enumerate(s):

    cnt[c].append(i)





def is_Lucky(x):

    x = '{:03d}'.format(x)

    if not cnt[x[0]]:

        return False

    idx = cnt[x[0]][0]

    for c in x[1:]:

        i = bisect.bisect_right(cnt[c], idx)

        if len(cnt[c]) == i:

            return False

        idx = cnt[c][i]

    else:

        return True





ans = 0

for i in range(1000):

    if is_Lucky(i):

        ans += 1

print(ans)
n = int(eval(input()))
s = list(map(int, eval(input())))


def is_Lucky(x):
    x = tuple(map(int, "{:03d}".format(x)))
    idx = 0
    for c in s:
        if x[idx] == c:
            idx += 1
            if idx == 3:
                return True
    else:
        return False


ans = 0
for i in range(1000):
    if is_Lucky(i):
        ans += 1
print(ans)

import bisect
from collections import defaultdict

n = int(eval(input()))
s = eval(input())
cnt = defaultdict(list)
for i, c in enumerate(s):
    cnt[c].append(i)


def is_Lucky(x):
    x = "{:03d}".format(x)
    if not cnt[x[0]]:
        return False
    idx = cnt[x[0]][0]
    for c in x[1:]:
        i = bisect.bisect_right(cnt[c], idx)
        if len(cnt[c]) == i:
            return False
        idx = cnt[c][i]
    else:
        return True


ans = 0
for i in range(1000):
    if is_Lucky(i):
        ans += 1
print(ans)

+import bisect +from collections import defaultdict + -s = list(map(int, eval(input()))) +s = eval(input()) +cnt = defaultdict(list) +for i, c in enumerate(s): +    cnt[c].append(i) -    x = tuple(map(int, "{:03d}".format(x))) -    idx = 0 -    for c in s: -        if x[idx] == c: -            idx += 1 -            if idx == 3: -                return True +    x = "{:03d}".format(x) +    if not cnt[x[0]]: +        return False +    idx = cnt[x[0]][0] +    for c in x[1:]: +        i = bisect.bisect_right(cnt[c], idx) +        if len(cnt[c]) == i: +            return False +        idx = cnt[c][i] -        return False +        return True