n=int(eval(input()))

s=list(eval(input()))

fa=[n+1]*10

la=[-1]*10

for i in range(n):

    s[i]=int(s[i])

    if fa[s[i]]>n:

        fa[s[i]]=i

    la[s[i]]=i

ans=0

for i in range(10):

    for j in range(10):

        if fa[i]<la[j]:

            num=[0]*10

            for k in range(fa[i]+1,la[j]):

                num[s[k]]=1

            ans+=num.count(1)

print(ans)

n=int(eval(input()))

s=list(eval(input()))

num=list(range(10))

for i in range(10):

    num[i]=str(num[i])

ans=0

for i in range(n-2):

    if len(num)==0:

        break

    if s[i] in num:

        num2=[str(_) for _ in range(10)]

        num.remove(s[i])

        for j in range(i+1,n):

            if len(num2)==0:

                break

            if s[j] in num2:

                num2.remove(s[j])

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

print(ans)

n = int(eval(input()))
s = list(eval(input()))
fa = [n + 1] * 10
la = [-1] * 10
for i in range(n):
    s[i] = int(s[i])
    if fa[s[i]] > n:
        fa[s[i]] = i
    la[s[i]] = i
ans = 0
for i in range(10):
    for j in range(10):
        if fa[i] < la[j]:
            num = [0] * 10
            for k in range(fa[i] + 1, la[j]):
                num[s[k]] = 1
            ans += num.count(1)
print(ans)

n = int(eval(input()))
s = list(eval(input()))
num = list(range(10))
for i in range(10):
    num[i] = str(num[i])
ans = 0
for i in range(n - 2):
    if len(num) == 0:
        break
    if s[i] in num:
        num2 = [str(_) for _ in range(10)]
        num.remove(s[i])
        for j in range(i + 1, n):
            if len(num2) == 0:
                break
            if s[j] in num2:
                num2.remove(s[j])
                ans += len(set(s[j + 1 :]))
print(ans)

-fa = [n + 1] * 10 -la = [-1] * 10 -for i in range(n): -    s[i] = int(s[i]) -    if fa[s[i]] > n: -        fa[s[i]] = i -    la[s[i]] = i +num = list(range(10)) +for i in range(10): +    num[i] = str(num[i]) -for i in range(10): -    for j in range(10): -        if fa[i] < la[j]: -            num = [0] * 10 -            for k in range(fa[i] + 1, la[j]): -                num[s[k]] = 1 -            ans += num.count(1) +for i in range(n - 2): +    if len(num) == 0: +        break +    if s[i] in num: +        num2 = [str(_) for _ in range(10)] +        num.remove(s[i]) +        for j in range(i + 1, n): +            if len(num2) == 0: +                break +            if s[j] in num2: +                num2.remove(s[j]) +                ans += len(set(s[j + 1 :]))