n=int(eval(input()))

s=eval(input())



cnt=0

for i in range(1000):

    num=str(i).zfill(3)

    add=0

    for j in s:

        if num[add]==j:add +=1

        if add==3:

            cnt +=1

            break

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

s=eval(input())



cnt=0

for i in range(1000):

    num=str(i).zfill(3)

    x=s.find(num[0])

    y=s.find(num[1],x+1)

    z=s.find(num[2],y+1)

    if x!=-1 and y!=-1 and z!=-1:

        cnt +=1



print(cnt)
n = int(eval(input()))
s = eval(input())
cnt = 0
for i in range(1000):
    num = str(i).zfill(3)
    add = 0
    for j in s:
        if num[add] == j:
            add += 1
        if add == 3:
            cnt += 1
            break
print(cnt)

n = int(eval(input()))
s = eval(input())
cnt = 0
for i in range(1000):
    num = str(i).zfill(3)
    x = s.find(num[0])
    y = s.find(num[1], x + 1)
    z = s.find(num[2], y + 1)
    if x != -1 and y != -1 and z != -1:
        cnt += 1
print(cnt)

-    add = 0 -    for j in s: -        if num[add] == j: -            add += 1 -        if add == 3: -            cnt += 1 -            break +    x = s.find(num[0]) +    y = s.find(num[1], x + 1) +    z = s.find(num[2], y + 1) +    if x != -1 and y != -1 and z != -1: +        cnt += 1