N = int(eval(input()))

S = list(eval(input()))



ans = 0



for n in range(1000):

    pin = str(n).zfill(3)

    head = 0

    for c in S:

        if c == pin[head]:

            head += 1

        if head == 3:

            ans += 1

            break



print(ans)

n = int(eval(input()))

s = eval(input())

ans = 0

for i in range(10):

    for  j in range(10):

        for k in range(10):

            i_index = s.find(str(i))

            if i_index > - 1:

                j_index = s.find(str(j), i_index + 1)

                if j_index > -1:

                    k_index = s.find(str(k), j_index + 1)

                    if k_index > -1:

                        ans += 1

print(ans)
N = int(eval(input()))
S = list(eval(input()))
ans = 0
for n in range(1000):
    pin = str(n).zfill(3)
    head = 0
    for c in S:
        if c == pin[head]:
            head += 1
        if head == 3:
            ans += 1
            break
print(ans)

n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            i_index = s.find(str(i))
            if i_index > -1:
                j_index = s.find(str(j), i_index + 1)
                if j_index > -1:
                    k_index = s.find(str(k), j_index + 1)
                    if k_index > -1:
                        ans += 1
print(ans)

-N = int(eval(input())) -S = list(eval(input())) +n = int(eval(input())) +s = eval(input()) -for n in range(1000): -    pin = str(n).zfill(3) -    head = 0 -    for c in S: -        if c == pin[head]: -            head += 1 -        if head == 3: -            ans += 1 -            break +for i in range(10): +    for j in range(10): +        for k in range(10): +            i_index = s.find(str(i)) +            if i_index > -1: +                j_index = s.find(str(j), i_index + 1) +                if j_index > -1: +                    k_index = s.find(str(k), j_index + 1) +                    if k_index > -1: +                        ans += 1