from collections import deque,defaultdict

def solve():

    N = int(eval(input()))

    S = list(eval(input()))

    dic = defaultdict(lambda: False)

    ans = 0

    d = deque()

    for s in S:

        for _ in range(len(d)):

            t = d.popleft()

            d.append(t)

            if len(t)==1:

                u = t+s

                if dic[u]==False:

                    dic[u] = True

                    d.append(u)

            if len(t)==2:

                u = t+s

                if dic[u]==False:

                    dic[u] = True

                    ans += 1

        if dic[s]==False:

            dic[s] = True

            d.append(s)

    return ans

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

s=eval(input())

ans=0

 

for i in range(10):

    x=s.find(str(i))

    if x!=-1:

        for j in range(10):

            y=s.find(str(j),x+1)

            if y!=-1:

                for k in range(10):

                    z=s.find(str(k),y+1)

                    if z!=-1:

                        ans+=1

print(ans)

from collections import deque, defaultdict


def solve():
    N = int(eval(input()))
    S = list(eval(input()))
    dic = defaultdict(lambda: False)
    ans = 0
    d = deque()
    for s in S:
        for _ in range(len(d)):
            t = d.popleft()
            d.append(t)
            if len(t) == 1:
                u = t + s
                if dic[u] == False:
                    dic[u] = True
                    d.append(u)
            if len(t) == 2:
                u = t + s
                if dic[u] == False:
                    dic[u] = True
                    ans += 1
        if dic[s] == False:
            dic[s] = True
            d.append(s)
    return ans


print((solve()))

n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(10):
    x = s.find(str(i))
    if x != -1:
        for j in range(10):
            y = s.find(str(j), x + 1)
            if y != -1:
                for k in range(10):
                    z = s.find(str(k), y + 1)
                    if z != -1:
                        ans += 1
print(ans)

-from collections import deque, defaultdict - - -def solve(): -    N = int(eval(input())) -    S = list(eval(input())) -    dic = defaultdict(lambda: False) -    ans = 0 -    d = deque() -    for s in S: -        for _ in range(len(d)): -            t = d.popleft() -            d.append(t) -            if len(t) == 1: -                u = t + s -                if dic[u] == False: -                    dic[u] = True -                    d.append(u) -            if len(t) == 2: -                u = t + s -                if dic[u] == False: -                    dic[u] = True -                    ans += 1 -        if dic[s] == False: -            dic[s] = True -            d.append(s) -    return ans - - -print((solve())) +n = int(eval(input())) +s = eval(input()) +ans = 0 +for i in range(10): +    x = s.find(str(i)) +    if x != -1: +        for j in range(10): +            y = s.find(str(j), x + 1) +            if y != -1: +                for k in range(10): +                    z = s.find(str(k), y + 1) +                    if z != -1: +                        ans += 1 +print(ans)