n = int(eval(input()))

S = str(eval(input()))

r = 0

for i in range(1000):

    t = "{0:03d}".format(i)

    j = 0

    for c in S:

        if t[j] == c:

            j += 1

        if j == 3:

            r += 1

            break

print(r)

n,S,r=int(eval(input())),eval(input()),0

dp1=[0]*n

dp2=[0]*n

d=set()

for i, c in enumerate(S):

    dp1[i] = len(d)

    d.add(c)



cs = [0 for i in range(10)]

d=set()

for i, c in enumerate(S[::-1]):

    dp2[i] = len(d)

    r += dp1[n-i-1]*(dp2[i]-dp2[cs[int(c)]])

    d.add(c)

    cs[int(c)] = i

print(r)

n = int(eval(input()))
S = str(eval(input()))
r = 0
for i in range(1000):
    t = "{0:03d}".format(i)
    j = 0
    for c in S:
        if t[j] == c:
            j += 1
        if j == 3:
            r += 1
            break
print(r)

n, S, r = int(eval(input())), eval(input()), 0
dp1 = [0] * n
dp2 = [0] * n
d = set()
for i, c in enumerate(S):
    dp1[i] = len(d)
    d.add(c)
cs = [0 for i in range(10)]
d = set()
for i, c in enumerate(S[::-1]):
    dp2[i] = len(d)
    r += dp1[n - i - 1] * (dp2[i] - dp2[cs[int(c)]])
    d.add(c)
    cs[int(c)] = i
print(r)

-n = int(eval(input())) -S = str(eval(input())) -r = 0 -for i in range(1000): -    t = "{0:03d}".format(i) -    j = 0 -    for c in S: -        if t[j] == c: -            j += 1 -        if j == 3: -            r += 1 -            break +n, S, r = int(eval(input())), eval(input()), 0 +dp1 = [0] * n +dp2 = [0] * n +d = set() +for i, c in enumerate(S): +    dp1[i] = len(d) +    d.add(c) +cs = [0 for i in range(10)] +d = set() +for i, c in enumerate(S[::-1]): +    dp2[i] = len(d) +    r += dp1[n - i - 1] * (dp2[i] - dp2[cs[int(c)]]) +    d.add(c) +    cs[int(c)] = i