N = int(eval(input()))

S = eval(input())

ans = 0

for i in range(1000):

    tmp = str(i)

    while len(tmp) < 3:

        tmp = '0' + tmp

    count = 0

    target = S

    for i in tmp:

        target = target.replace(i,'')

    for k in S:

        if 3 <= count:

            break

        if k == tmp[count]:

            count += 1

    if count == 3:

        ans += 1

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

S = eval(input())

first_check = [0] * 10

ans = 0

for i in range(N):

    if first_check[int(S[i])] == 1:

        continue

    second_check = [0] * 10

    for k in range(i+1,N):

        if second_check[int(S[k])] == 1:

            continue

        ans += len(set(list(S[k+1:])))

        second_check[int(S[k])] = 1

    first_check[int(S[i])] = 1

print(ans)
N = int(eval(input()))
S = eval(input())
ans = 0
for i in range(1000):
    tmp = str(i)
    while len(tmp) < 3:
        tmp = "0" + tmp
    count = 0
    target = S
    for i in tmp:
        target = target.replace(i, "")
    for k in S:
        if 3 <= count:
            break
        if k == tmp[count]:
            count += 1
    if count == 3:
        ans += 1
print(ans)

N = int(eval(input()))
S = eval(input())
first_check = [0] * 10
ans = 0
for i in range(N):
    if first_check[int(S[i])] == 1:
        continue
    second_check = [0] * 10
    for k in range(i + 1, N):
        if second_check[int(S[k])] == 1:
            continue
        ans += len(set(list(S[k + 1 :])))
        second_check[int(S[k])] = 1
    first_check[int(S[i])] = 1
print(ans)

+first_check = [0] * 10 -for i in range(1000): -    tmp = str(i) -    while len(tmp) < 3: -        tmp = "0" + tmp -    count = 0 -    target = S -    for i in tmp: -        target = target.replace(i, "") -    for k in S: -        if 3 <= count: -            break -        if k == tmp[count]: -            count += 1 -    if count == 3: -        ans += 1 +for i in range(N): +    if first_check[int(S[i])] == 1: +        continue +    second_check = [0] * 10 +    for k in range(i + 1, N): +        if second_check[int(S[k])] == 1: +            continue +        ans += len(set(list(S[k + 1 :]))) +        second_check[int(S[k])] = 1 +    first_check[int(S[i])] = 1