import bisect

N = int(eval(input()))

S = eval(input())

X = [[] for i in range(10)]

for i in range(len(S)):

    S_tmp = int(S[i])

    X[S_tmp].append(i)

ans = 0

for i in range(1000):

    i_tmp = i+1000

    p = [0]*3

    for j in range(3):

        p[j] = int(str(i_tmp)[j+1])

    if len(X[p[0]]) != 0:

        x1 = X[p[0]][0]

        if len(X[p[1]]) != 0:

            x2 = bisect.bisect_right(X[p[1]],x1)

            if x2 != len(X[p[1]]):

                x2 = X[p[1]][x2]

                if len(X[p[2]]) != 0:

                    x3 = X[p[2]][-1]

                    if x3 > x2 and x3 > x1:

                        ans += 1

print(ans)

N = int(eval(input()))

S = eval(input())

re = 0

for i in range(1000):

    ans = [0]*3

    for j in range(3):

        ans[j] = str(i % 10)

        i = i // 10

    ans.reverse()

    flag = False

    idx_left = S.find(ans[0])

    idx_right = S.rfind(ans[2])

    if idx_left != -1 and idx_right != -1 and idx_left < idx_right:

        if ans[1] in S[idx_left+1:idx_right]:

            flag = True

    if flag:

        re += 1

print(re)
import bisect

N = int(eval(input()))
S = eval(input())
X = [[] for i in range(10)]
for i in range(len(S)):
    S_tmp = int(S[i])
    X[S_tmp].append(i)
ans = 0
for i in range(1000):
    i_tmp = i + 1000
    p = [0] * 3
    for j in range(3):
        p[j] = int(str(i_tmp)[j + 1])
    if len(X[p[0]]) != 0:
        x1 = X[p[0]][0]
        if len(X[p[1]]) != 0:
            x2 = bisect.bisect_right(X[p[1]], x1)
            if x2 != len(X[p[1]]):
                x2 = X[p[1]][x2]
                if len(X[p[2]]) != 0:
                    x3 = X[p[2]][-1]
                    if x3 > x2 and x3 > x1:
                        ans += 1
print(ans)

N = int(eval(input()))
S = eval(input())
re = 0
for i in range(1000):
    ans = [0] * 3
    for j in range(3):
        ans[j] = str(i % 10)
        i = i // 10
    ans.reverse()
    flag = False
    idx_left = S.find(ans[0])
    idx_right = S.rfind(ans[2])
    if idx_left != -1 and idx_right != -1 and idx_left < idx_right:
        if ans[1] in S[idx_left + 1 : idx_right]:
            flag = True
    if flag:
        re += 1
print(re)

-import bisect - -X = [[] for i in range(10)] -for i in range(len(S)): -    S_tmp = int(S[i]) -    X[S_tmp].append(i) -ans = 0 +re = 0 -    i_tmp = i + 1000 -    p = [0] * 3 +    ans = [0] * 3 -        p[j] = int(str(i_tmp)[j + 1]) -    if len(X[p[0]]) != 0: -        x1 = X[p[0]][0] -        if len(X[p[1]]) != 0: -            x2 = bisect.bisect_right(X[p[1]], x1) -            if x2 != len(X[p[1]]): -                x2 = X[p[1]][x2] -                if len(X[p[2]]) != 0: -                    x3 = X[p[2]][-1] -                    if x3 > x2 and x3 > x1: -                        ans += 1 -print(ans) +        ans[j] = str(i % 10) +        i = i // 10 +    ans.reverse() +    flag = False +    idx_left = S.find(ans[0]) +    idx_right = S.rfind(ans[2]) +    if idx_left != -1 and idx_right != -1 and idx_left < idx_right: +        if ans[1] in S[idx_left + 1 : idx_right]: +            flag = True +    if flag: +        re += 1 +print(re)