N = int(eval(input()))

S = eval(input())



ans = 0

for n in range(1000):

    c = [n // 100, (n // 10) % 10, n % 10]

    f = 0

    for i in range(N):

        if S[i] == str(c[f]):

            f += 1

        if f == 3:

            break

    

    if f == 3:

        ans += 1

        

print(ans)



N = int(eval(input()))

S = eval(input())



ans = 0

for n in range(1000):

    target = "{:03}".format(n)

    j = 0

    for i in range(N):

        if S[i] == target[j]:

            j += 1

        if j == 3:

            ans += 1

            break



print(ans)

N = int(eval(input()))
S = eval(input())
ans = 0
for n in range(1000):
    c = [n // 100, (n // 10) % 10, n % 10]
    f = 0
    for i in range(N):
        if S[i] == str(c[f]):
            f += 1
        if f == 3:
            break
    if f == 3:
        ans += 1
print(ans)

N = int(eval(input()))
S = eval(input())
ans = 0
for n in range(1000):
    target = "{:03}".format(n)
    j = 0
    for i in range(N):
        if S[i] == target[j]:
            j += 1
        if j == 3:
            ans += 1
            break
print(ans)

-    c = [n // 100, (n // 10) % 10, n % 10] -    f = 0 +    target = "{:03}".format(n) +    j = 0 -        if S[i] == str(c[f]): -            f += 1 -        if f == 3: +        if S[i] == target[j]: +            j += 1 +        if j == 3: +            ans += 1 -    if f == 3: -        ans += 1