N=int(eval(input()))

S=eval(input())

ans=[set(),set(),set()]

for i in S:

    for j in ans[1]:

        ans[2].add(j+i)

    for j in ans[0]:

        ans[1].add(j+i)

    ans[0].add(i)

print((len(ans[2])))
N=int(eval(input()))

S=eval(input())

ans=0

for i in range(1000):

    t=str(i).zfill(3)

    a=S.find(t[0])

    b=S.find(t[1],a+1)

    c=S.find(t[2],b+1)

    if a!=-1 and b!=-1 and c!=-1:

        ans+=1

print(ans)
N = int(eval(input()))
S = eval(input())
ans = [set(), set(), set()]
for i in S:
    for j in ans[1]:
        ans[2].add(j + i)
    for j in ans[0]:
        ans[1].add(j + i)
    ans[0].add(i)
print((len(ans[2])))

N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1000):
    t = str(i).zfill(3)
    a = S.find(t[0])
    b = S.find(t[1], a + 1)
    c = S.find(t[2], b + 1)
    if a != -1 and b != -1 and c != -1:
        ans += 1
print(ans)

-ans = [set(), set(), set()] -for i in S: -    for j in ans[1]: -        ans[2].add(j + i) -    for j in ans[0]: -        ans[1].add(j + i) -    ans[0].add(i) -print((len(ans[2]))) +ans = 0 +for i in range(1000): +    t = str(i).zfill(3) +    a = S.find(t[0]) +    b = S.find(t[1], a + 1) +    c = S.find(t[2], b + 1) +    if a != -1 and b != -1 and c != -1: +        ans += 1 +print(ans)