N = int(eval(input()))

Ss = eval(input())



used1s = [False] * 10

used2s = [False] * 100

used3s = [False] * 1000



for S in Ss:

    S = int(S)

    for x in range(100):

        if used2s[x]:

            used3s[x*10+S] = True

    for x in range(10):

        if used1s[x]:

            used2s[x*10+S] = True

    used1s[S] = True



ans = used3s.count(True)

print(ans)

N = int(eval(input()))

Ss = eval(input())



ans = 0

for P in range(1000):

    Ds = str(P).zfill(3)

    pos = -1

    for D in Ds:

        pos = Ss.find(D, pos+1)

        if pos == -1:

            break

    else:

        ans += 1



print(ans)

N = int(eval(input()))
Ss = eval(input())
used1s = [False] * 10
used2s = [False] * 100
used3s = [False] * 1000
for S in Ss:
    S = int(S)
    for x in range(100):
        if used2s[x]:
            used3s[x * 10 + S] = True
    for x in range(10):
        if used1s[x]:
            used2s[x * 10 + S] = True
    used1s[S] = True
ans = used3s.count(True)
print(ans)

N = int(eval(input()))
Ss = eval(input())
ans = 0
for P in range(1000):
    Ds = str(P).zfill(3)
    pos = -1
    for D in Ds:
        pos = Ss.find(D, pos + 1)
        if pos == -1:
            break
    else:
        ans += 1
print(ans)

-used1s = [False] * 10 -used2s = [False] * 100 -used3s = [False] * 1000 -for S in Ss: -    S = int(S) -    for x in range(100): -        if used2s[x]: -            used3s[x * 10 + S] = True -    for x in range(10): -        if used1s[x]: -            used2s[x * 10 + S] = True -    used1s[S] = True -ans = used3s.count(True) +ans = 0 +for P in range(1000): +    Ds = str(P).zfill(3) +    pos = -1 +    for D in Ds: +        pos = Ss.find(D, pos + 1) +        if pos == -1: +            break +    else: +        ans += 1