n=int(eval(input()))

s=eval(input())

ans=0

for i in range(1000):

  tmp=str(i)

  while len(tmp)<3:

    tmp="0"+tmp

  j=0



  for k in range(n):

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

      j+=1

    if j==3:

      ans+=1

      break

print(ans)
import sys

def input():

    return sys.stdin.readline()[:-1]

inf=float("inf")

n=int(eval(input()))

s=eval(input())

li=[[-1]*10 for i in range(n+1)]

for i in range(n):

    li[-i-2]=li[-i-1][:]

    li[-i-2][int(s[-i-1])]=n-1-i



ans=0

for i in range(1000):

    tmp=str(i)

    while len(tmp)!=3:

        tmp= "0"+tmp

    now=0

    for j in range(3):

        if li[now][int(tmp[j])]==-1:

            break

        now=li[now][int(tmp[j])]+1

        if j==2:

            ans+=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
    j = 0
    for k in range(n):
        if tmp[j] == s[k]:
            j += 1
        if j == 3:
            ans += 1
            break
print(ans)

import sys


def input():
    return sys.stdin.readline()[:-1]


inf = float("inf")
n = int(eval(input()))
s = eval(input())
li = [[-1] * 10 for i in range(n + 1)]
for i in range(n):
    li[-i - 2] = li[-i - 1][:]
    li[-i - 2][int(s[-i - 1])] = n - 1 - i
ans = 0
for i in range(1000):
    tmp = str(i)
    while len(tmp) != 3:
        tmp = "0" + tmp
    now = 0
    for j in range(3):
        if li[now][int(tmp[j])] == -1:
            break
        now = li[now][int(tmp[j])] + 1
        if j == 2:
            ans += 1
print(ans)

+import sys + + +def input(): +    return sys.stdin.readline()[:-1] + + +inf = float("inf") +li = [[-1] * 10 for i in range(n + 1)] +for i in range(n): +    li[-i - 2] = li[-i - 1][:] +    li[-i - 2][int(s[-i - 1])] = n - 1 - i -    while len(tmp) < 3: +    while len(tmp) != 3: -    j = 0 -    for k in range(n): -        if tmp[j] == s[k]: -            j += 1 -        if j == 3: +    now = 0 +    for j in range(3): +        if li[now][int(tmp[j])] == -1: +            break +        now = li[now][int(tmp[j])] + 1 +        if j == 2: -            break