N = int(eval(input()))

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

def judge(x,l):

  ret = False

  num = 0

  for a,n in enumerate(l):

    if n==x:

      ret = True

      num = a

      break

      

  return ret,num



ans = 0

for i in range(10):

  tf1,n1 = judge(i,S)

  if tf1:

    for j in range(10):

      tf2,n2 = judge(j,S[n1+1:])

      if tf2:

        for k in range(10):

          tf3,n3=judge(k,S[n1+n2+2:])

          if tf3:

            ans+=1



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

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

S_riv=S[::-1]

l_lis=[0]*N

r_lis=[0]*N

mat=([set([])for j in range(10)])

l_set=set([])

r_set=set([])

for i,s in enumerate(S):

  l_lis[i]=l_set.copy()

  l_set.add(s)

  

for i,s in enumerate(S_riv):

  r_lis[i]=r_set.copy()

  r_set.add(s)

  

r_lis.reverse()

ans=0

for i,s in enumerate(S):

  ans+=len(l_lis[i]-mat[s])*len(r_lis[i])

  mat[s]=l_lis[i]

  

print(ans)
N = int(eval(input()))
S = list(map(int, list(eval(input()))))


def judge(x, l):
    ret = False
    num = 0
    for a, n in enumerate(l):
        if n == x:
            ret = True
            num = a
            break
    return ret, num


ans = 0
for i in range(10):
    tf1, n1 = judge(i, S)
    if tf1:
        for j in range(10):
            tf2, n2 = judge(j, S[n1 + 1 :])
            if tf2:
                for k in range(10):
                    tf3, n3 = judge(k, S[n1 + n2 + 2 :])
                    if tf3:
                        ans += 1
print(ans)

N = int(eval(input()))
S = list(map(int, list(eval(input()))))
S_riv = S[::-1]
l_lis = [0] * N
r_lis = [0] * N
mat = [set([]) for j in range(10)]
l_set = set([])
r_set = set([])
for i, s in enumerate(S):
    l_lis[i] = l_set.copy()
    l_set.add(s)
for i, s in enumerate(S_riv):
    r_lis[i] = r_set.copy()
    r_set.add(s)
r_lis.reverse()
ans = 0
for i, s in enumerate(S):
    ans += len(l_lis[i] - mat[s]) * len(r_lis[i])
    mat[s] = l_lis[i]
print(ans)

- - -def judge(x, l): -    ret = False -    num = 0 -    for a, n in enumerate(l): -        if n == x: -            ret = True -            num = a -            break -    return ret, num - - +S_riv = S[::-1] +l_lis = [0] * N +r_lis = [0] * N +mat = [set([]) for j in range(10)] +l_set = set([]) +r_set = set([]) +for i, s in enumerate(S): +    l_lis[i] = l_set.copy() +    l_set.add(s) +for i, s in enumerate(S_riv): +    r_lis[i] = r_set.copy() +    r_set.add(s) +r_lis.reverse() -for i in range(10): -    tf1, n1 = judge(i, S) -    if tf1: -        for j in range(10): -            tf2, n2 = judge(j, S[n1 + 1 :]) -            if tf2: -                for k in range(10): -                    tf3, n3 = judge(k, S[n1 + n2 + 2 :]) -                    if tf3: -                        ans += 1 +for i, s in enumerate(S): +    ans += len(l_lis[i] - mat[s]) * len(r_lis[i]) +    mat[s] = l_lis[i]