n = int(eval(input()))

s = list(map(int, list(eval(input()))))

ans = 0

for i in range(1000):

    c = 0

    for j in s:

        if i % 10 == j:

            if c == 2:

                ans += 1

                break

            c += 1

            i //= 10

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

s = list(map(int, list(eval(input()))))

idx = [[] for _ in range(10)]

for i, v in enumerate(s):

    idx[v].append(i)



ans = 0

for i in range(1000):

    c = 0

    p = -1

    chk = True

    while c < 3 and chk:

        chk = False

        for j in idx[i // 100]:

            if j > p:

                c += 1

                p = j

                chk = True

                i = i % 100 * 10

                break

    if c == 3:

        ans += 1

print(ans)
n = int(eval(input()))
s = list(map(int, list(eval(input()))))
ans = 0
for i in range(1000):
    c = 0
    for j in s:
        if i % 10 == j:
            if c == 2:
                ans += 1
                break
            c += 1
            i //= 10
print(ans)

n = int(eval(input()))
s = list(map(int, list(eval(input()))))
idx = [[] for _ in range(10)]
for i, v in enumerate(s):
    idx[v].append(i)
ans = 0
for i in range(1000):
    c = 0
    p = -1
    chk = True
    while c < 3 and chk:
        chk = False
        for j in idx[i // 100]:
            if j > p:
                c += 1
                p = j
                chk = True
                i = i % 100 * 10
                break
    if c == 3:
        ans += 1
print(ans)

+idx = [[] for _ in range(10)] +for i, v in enumerate(s): +    idx[v].append(i) -    for j in s: -        if i % 10 == j: -            if c == 2: -                ans += 1 +    p = -1 +    chk = True +    while c < 3 and chk: +        chk = False +        for j in idx[i // 100]: +            if j > p: +                c += 1 +                p = j +                chk = True +                i = i % 100 * 10 -            c += 1 -            i //= 10 +    if c == 3: +        ans += 1