n = int(eval(input()))

s = eval(input())

ans = 0

for i in range(1000):

    count = 0

    index = 0

    i = str(i)

    if len(i) < 2:

        i = "00"+i

    elif len(i) < 3:

        i = "0"+i

    for j in i:

        for k in range(index, n):

            if j == s[k]:

                index = k+1

                count += 1

                break

    if count == 3:

        ans += 1

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

s = eval(input())

ans = 0

for i in range(1000):

    index = 0

    i = str(i)

    if len(i) < 2:

        i = "00"+i

    elif len(i) < 3:

        i = "0"+i

    for j in s:

        if i[index] == j:

            index += 1

        if index == 3:

            ans += 1

            break

print(ans)
n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
    count = 0
    index = 0
    i = str(i)
    if len(i) < 2:
        i = "00" + i
    elif len(i) < 3:
        i = "0" + i
    for j in i:
        for k in range(index, n):
            if j == s[k]:
                index = k + 1
                count += 1
                break
    if count == 3:
        ans += 1
print(ans)

n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
    index = 0
    i = str(i)
    if len(i) < 2:
        i = "00" + i
    elif len(i) < 3:
        i = "0" + i
    for j in s:
        if i[index] == j:
            index += 1
        if index == 3:
            ans += 1
            break
print(ans)

-    count = 0 -    for j in i: -        for k in range(index, n): -            if j == s[k]: -                index = k + 1 -                count += 1 -                break -    if count == 3: -        ans += 1 +    for j in s: +        if i[index] == j: +            index += 1 +        if index == 3: +            ans += 1 +            break