n=int(eval(input()))

s=list(eval(input()))

cnt=0

for i in range(1000):

    num=str(i).zfill(3)

    base=s

    for k,j in enumerate(num):

        if j in base:base=base[base.index(j)+1:]

        else:break

        if k==2:cnt +=1

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 = list(eval(input()))
cnt = 0
for i in range(1000):
    num = str(i).zfill(3)
    base = s
    for k, j in enumerate(num):
        if j in base:
            base = base[base.index(j) + 1 :]
        else:
            break
        if k == 2:
            cnt += 1
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)

-s = list(eval(input())) +s = eval(input()) -    base = s -    for k, j in enumerate(num): -        if j in base: -            base = base[base.index(j) + 1 :] -        else: -            break -        if k == 2: -            cnt += 1 +    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