from collections import defaultdict

n = int(eval(input()))

S = eval(input())



d = defaultdict(list)

for i, s in enumerate(S):

    d[s].append(i)



ans = 0

for p in range(1000):

    p1, p2, p3 = str(p).zfill(3)



    i0 = -1

    for i in d[p1]:

        if i > i0:

            i1 = i

            break

    else:

        continue



    for i in d[p2]:

        if i > i1:

            i2 = i

            break

    else:

        continue



    for i in d[p3]:

        if i > i2:

            ans += 1

            break





print(ans)

N = int(eval(input()))

S = eval(input())



ans = 0

for x in range(0, 1000):

    pin = str(x).zfill(3)



    i = S.find(pin[0])

    if i == -1:

        continue

    i = S.find(pin[1], i + 1)

    if i == -1:

        continue

    i = S.find(pin[2], i + 1)

    if i == -1:

        continue

    ans += 1



print(ans)

from collections import defaultdict

n = int(eval(input()))
S = eval(input())
d = defaultdict(list)
for i, s in enumerate(S):
    d[s].append(i)
ans = 0
for p in range(1000):
    p1, p2, p3 = str(p).zfill(3)
    i0 = -1
    for i in d[p1]:
        if i > i0:
            i1 = i
            break
    else:
        continue
    for i in d[p2]:
        if i > i1:
            i2 = i
            break
    else:
        continue
    for i in d[p3]:
        if i > i2:
            ans += 1
            break
print(ans)

N = int(eval(input()))
S = eval(input())
ans = 0
for x in range(0, 1000):
    pin = str(x).zfill(3)
    i = S.find(pin[0])
    if i == -1:
        continue
    i = S.find(pin[1], i + 1)
    if i == -1:
        continue
    i = S.find(pin[2], i + 1)
    if i == -1:
        continue
    ans += 1
print(ans)

-from collections import defaultdict - -n = int(eval(input())) +N = int(eval(input())) -d = defaultdict(list) -for i, s in enumerate(S): -    d[s].append(i) -for p in range(1000): -    p1, p2, p3 = str(p).zfill(3) -    i0 = -1 -    for i in d[p1]: -        if i > i0: -            i1 = i -            break -    else: +for x in range(0, 1000): +    pin = str(x).zfill(3) +    i = S.find(pin[0]) +    if i == -1: -    for i in d[p2]: -        if i > i1: -            i2 = i -            break -    else: +    i = S.find(pin[1], i + 1) +    if i == -1: -    for i in d[p3]: -        if i > i2: -            ans += 1 -            break +    i = S.find(pin[2], i + 1) +    if i == -1: +        continue +    ans += 1