n = int(eval(input()))

s = eval(input())

c1 = [0] * 10

c2 = [0] * 100

c3 = [0] * 1000

for i in s:

  i = int(i)

  for j in range(100):

    c3[j*10+i] = c2[j]

  for j in range(10):

    c2[j*10+i] = c1[j]

  c1[i] = 1

print((sum(c3)))
from collections import defaultdict

import bisect

n = int(eval(input()))

d = defaultdict(list)

for i,j in enumerate(eval(input())):

  j = int(j)

  d[j].append(i)

c = 0

for i in range(10):

  for j in range(10):

    for k in range(10):

      if d[i] != [] and d[j] != [] and d[k] != []:

        b = bisect.bisect_right(d[j],d[i][0])

        if b != len(d[j]) and d[j][b] < d[k][-1]:

          c += 1

print(c)
n = int(eval(input()))
s = eval(input())
c1 = [0] * 10
c2 = [0] * 100
c3 = [0] * 1000
for i in s:
    i = int(i)
    for j in range(100):
        c3[j * 10 + i] = c2[j]
    for j in range(10):
        c2[j * 10 + i] = c1[j]
    c1[i] = 1
print((sum(c3)))

from collections import defaultdict
import bisect

n = int(eval(input()))
d = defaultdict(list)
for i, j in enumerate(eval(input())):
    j = int(j)
    d[j].append(i)
c = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            if d[i] != [] and d[j] != [] and d[k] != []:
                b = bisect.bisect_right(d[j], d[i][0])
                if b != len(d[j]) and d[j][b] < d[k][-1]:
                    c += 1
print(c)

+from collections import defaultdict +import bisect + -s = eval(input()) -c1 = [0] * 10 -c2 = [0] * 100 -c3 = [0] * 1000 -for i in s: -    i = int(i) -    for j in range(100): -        c3[j * 10 + i] = c2[j] +d = defaultdict(list) +for i, j in enumerate(eval(input())): +    j = int(j) +    d[j].append(i) +c = 0 +for i in range(10): -        c2[j * 10 + i] = c1[j] -    c1[i] = 1 -print((sum(c3))) +        for k in range(10): +            if d[i] != [] and d[j] != [] and d[k] != []: +                b = bisect.bisect_right(d[j], d[i][0]) +                if b != len(d[j]) and d[j][b] < d[k][-1]: +                    c += 1 +print(c)