def count_2chr(li):

    ans = [0 for _ in range(10)]

    s = li.copy()

    while len(s) >= 2:

        i = s.pop(0)

        if ans[i] == 0:

            ans[i] = len(set(s))

    

    return sum(ans)



n = int(eval(input()))

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



count = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]



while len(s) >= 3:

    i = s.pop(0)

    if count[i] == 0:

        count[i] = count_2chr(s)



print((sum(count)))

n = int(eval(input()))

s = eval(input())



ans = 0



for i in range(100):

    num = str(i).zfill(2)

    k = 0

    for j in range(len(s)):

        if num[k] == s[j]:

            k += 1

        if k == 2:

            ans += len(set(s[j+1:]))

            break



print(ans)

def count_2chr(li):
    ans = [0 for _ in range(10)]
    s = li.copy()
    while len(s) >= 2:
        i = s.pop(0)
        if ans[i] == 0:
            ans[i] = len(set(s))
    return sum(ans)


n = int(eval(input()))
s = list(map(int, list(eval(input()))))
count = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
while len(s) >= 3:
    i = s.pop(0)
    if count[i] == 0:
        count[i] = count_2chr(s)
print((sum(count)))

n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(100):
    num = str(i).zfill(2)
    k = 0
    for j in range(len(s)):
        if num[k] == s[j]:
            k += 1
        if k == 2:
            ans += len(set(s[j + 1 :]))
            break
print(ans)

-def count_2chr(li): -    ans = [0 for _ in range(10)] -    s = li.copy() -    while len(s) >= 2: -        i = s.pop(0) -        if ans[i] == 0: -            ans[i] = len(set(s)) -    return sum(ans) - - -s = list(map(int, list(eval(input())))) -count = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] -while len(s) >= 3: -    i = s.pop(0) -    if count[i] == 0: -        count[i] = count_2chr(s) -print((sum(count))) +s = eval(input()) +ans = 0 +for i in range(100): +    num = str(i).zfill(2) +    k = 0 +    for j in range(len(s)): +        if num[k] == s[j]: +            k += 1 +        if k == 2: +            ans += len(set(s[j + 1 :])) +            break +print(ans)