n = int(eval(input()))

s = list(eval(input()))[::-1]

result = 0

for i in range(1000):

    x = format(i, "03")

    j = 0

    p = 0

    while p < n:

        if s[p]==x[j]:

            j += 1

            if j == 3:

                result += 1

                break

        p += 1



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

s = eval(input())

result = 0

for i in range(1000):

    x = format(i, "03")

    indx = s.find(x[0],0)

    indx1 = s.find(x[1], indx+1)

    indx2 = s.find(x[2], indx1+1)

    if indx>=0 and indx1>0 and indx2>0:

        result += 1



print(result)
n = int(eval(input()))
s = list(eval(input()))[::-1]
result = 0
for i in range(1000):
    x = format(i, "03")
    j = 0
    p = 0
    while p < n:
        if s[p] == x[j]:
            j += 1
            if j == 3:
                result += 1
                break
        p += 1
print(result)

n = int(eval(input()))
s = eval(input())
result = 0
for i in range(1000):
    x = format(i, "03")
    indx = s.find(x[0], 0)
    indx1 = s.find(x[1], indx + 1)
    indx2 = s.find(x[2], indx1 + 1)
    if indx >= 0 and indx1 > 0 and indx2 > 0:
        result += 1
print(result)

-s = list(eval(input()))[::-1] +s = eval(input()) -    j = 0 -    p = 0 -    while p < n: -        if s[p] == x[j]: -            j += 1 -            if j == 3: -                result += 1 -                break -        p += 1 +    indx = s.find(x[0], 0) +    indx1 = s.find(x[1], indx + 1) +    indx2 = s.find(x[2], indx1 + 1) +    if indx >= 0 and indx1 > 0 and indx2 > 0: +        result += 1