n = int(eval(input()))

s= eval(input())



next_ = [[-1]*(n+1) for i in range(10)]

for num in range(10):

    pos = -1

    for i in range(n)[::-1]:

        next_[num][i] = pos

        if num == int(s[i]):

            pos = i



start = [-1] * 10

for num in range(10):

    for i in range(n)[::-1]:

        if num == int(s[i]):

            start[num] = i

ans = 0

for i in range(1000):

    t = ("000"+str(i))[::-1][0:3][::-1]

    pos = start[int(t[0])]

    for i in t[1:]:

        pos = next_[int(i)][pos]

    if pos != -1:

        ans += 1

print(ans)
n = int(eval(input()))

s = eval(input())



alph = "0123456789"

next_ = [[-1] * (n + 1) for i in range(len(alph))]

for ai in range(len(alph)):

    tmp = - 1

    for si in range(n)[::-1]:

        if s[si] == alph[ai]:

            tmp = si + 1

        next_[ai][si] = tmp



ans = 0

for i in range(10):

    for j in range(10):

        for k in range(10):

            tmp = next_[i][0]

            tmp = next_[j][tmp]

            tmp = next_[k][tmp]

            if tmp != -1:

                ans += 1

print(ans)
n = int(eval(input()))
s = eval(input())
next_ = [[-1] * (n + 1) for i in range(10)]
for num in range(10):
    pos = -1
    for i in range(n)[::-1]:
        next_[num][i] = pos
        if num == int(s[i]):
            pos = i
start = [-1] * 10
for num in range(10):
    for i in range(n)[::-1]:
        if num == int(s[i]):
            start[num] = i
ans = 0
for i in range(1000):
    t = ("000" + str(i))[::-1][0:3][::-1]
    pos = start[int(t[0])]
    for i in t[1:]:
        pos = next_[int(i)][pos]
    if pos != -1:
        ans += 1
print(ans)

n = int(eval(input()))
s = eval(input())
alph = "0123456789"
next_ = [[-1] * (n + 1) for i in range(len(alph))]
for ai in range(len(alph)):
    tmp = -1
    for si in range(n)[::-1]:
        if s[si] == alph[ai]:
            tmp = si + 1
        next_[ai][si] = tmp
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tmp = next_[i][0]
            tmp = next_[j][tmp]
            tmp = next_[k][tmp]
            if tmp != -1:
                ans += 1
print(ans)

-next_ = [[-1] * (n + 1) for i in range(10)] -for num in range(10): -    pos = -1 -    for i in range(n)[::-1]: -        next_[num][i] = pos -        if num == int(s[i]): -            pos = i -start = [-1] * 10 -for num in range(10): -    for i in range(n)[::-1]: -        if num == int(s[i]): -            start[num] = i +alph = "0123456789" +next_ = [[-1] * (n + 1) for i in range(len(alph))] +for ai in range(len(alph)): +    tmp = -1 +    for si in range(n)[::-1]: +        if s[si] == alph[ai]: +            tmp = si + 1 +        next_[ai][si] = tmp -for i in range(1000): -    t = ("000" + str(i))[::-1][0:3][::-1] -    pos = start[int(t[0])] -    for i in t[1:]: -        pos = next_[int(i)][pos] -    if pos != -1: -        ans += 1 +for i in range(10): +    for j in range(10): +        for k in range(10): +            tmp = next_[i][0] +            tmp = next_[j][tmp] +            tmp = next_[k][tmp] +            if tmp != -1: +                ans += 1