N = int(eval(input()))

S = eval(input())



ans = 0

for i in range(1000):

    a, b, c = list(map(str, list(str(i).zfill(3))))

    mode = 'a'

    for j in S:

        if mode == 'a' and j == a:

            mode = 'b'

        elif mode == 'b' and j == b:

            mode = 'c'

        elif mode == 'c' and j == c:

            ans += 1

            break

print(ans)
N = eval(input())

S = eval(input())



ans = 0

for i in range(1000):

    code = str(i).zfill(3)

    j = 0

    for s in S:

        if s == code[j]:

            j += 1

            if j == 3:

                ans += 1

                break

print(ans)
N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1000):
    a, b, c = list(map(str, list(str(i).zfill(3))))
    mode = "a"
    for j in S:
        if mode == "a" and j == a:
            mode = "b"
        elif mode == "b" and j == b:
            mode = "c"
        elif mode == "c" and j == c:
            ans += 1
            break
print(ans)

N = eval(input())
S = eval(input())
ans = 0
for i in range(1000):
    code = str(i).zfill(3)
    j = 0
    for s in S:
        if s == code[j]:
            j += 1
            if j == 3:
                ans += 1
                break
print(ans)

-N = int(eval(input())) +N = eval(input()) -    a, b, c = list(map(str, list(str(i).zfill(3)))) -    mode = "a" -    for j in S: -        if mode == "a" and j == a: -            mode = "b" -        elif mode == "b" and j == b: -            mode = "c" -        elif mode == "c" and j == c: -            ans += 1 -            break +    code = str(i).zfill(3) +    j = 0 +    for s in S: +        if s == code[j]: +            j += 1 +            if j == 3: +                ans += 1 +                break