n=int(eval(input()))



s=eval(input()) 



ans = 0



for i in range(1000):

    count = 0

    i = str(i)

    i = (3-len(i))*'0'+i

    for j in range(n):

        if i[count] == s[j]:

            count += 1

        if count == 3:

            break

    if count == 3:

        ans += 1

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



s=list(eval(input()))



ans = 0



for i in range(1000):

    i = str(i)

    keta = len(list(i))

    code = '0'*(3-keta)+i

    code = list(code)

    index = 0

    for j in s:

        if j == code[index]:

            index += 1

        if index == 3:

            break

    if index == 3:

        #print(code)

        ans += 1

print(ans)
n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
    count = 0
    i = str(i)
    i = (3 - len(i)) * "0" + i
    for j in range(n):
        if i[count] == s[j]:
            count += 1
        if count == 3:
            break
    if count == 3:
        ans += 1
print(ans)

n = int(eval(input()))
s = list(eval(input()))
ans = 0
for i in range(1000):
    i = str(i)
    keta = len(list(i))
    code = "0" * (3 - keta) + i
    code = list(code)
    index = 0
    for j in s:
        if j == code[index]:
            index += 1
        if index == 3:
            break
    if index == 3:
        # print(code)
        ans += 1
print(ans)

-s = eval(input()) +s = list(eval(input())) -    count = 0 -    i = (3 - len(i)) * "0" + i -    for j in range(n): -        if i[count] == s[j]: -            count += 1 -        if count == 3: +    keta = len(list(i)) +    code = "0" * (3 - keta) + i +    code = list(code) +    index = 0 +    for j in s: +        if j == code[index]: +            index += 1 +        if index == 3: -    if count == 3: +    if index == 3: +        # print(code)