n= int(eval(input()))

s = eval(input())

ans = 0

h = set()

for i in range(n-2):

  ten = set()

  if s[i] not in h:

    h.add(s[i])

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

      if s[j] not in ten:

        ten.add(s[j])

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

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

s = eval(input())

ans = 0

for i in range(10):

  ii = s.find(str(i))

  if -1 == ii:

    continue

  for j in range(10):

    ij = s.find(str(j), ii+1)

    if -1 == ij:

      continue

    for k in range(10):

      ik = s.find(str(k), ij+1)

      if ik != -1:

        ans += 1

      

print(ans)
n = int(eval(input()))
s = eval(input())
ans = 0
h = set()
for i in range(n - 2):
    ten = set()
    if s[i] not in h:
        h.add(s[i])
        for j in range(i + 1, n - 1):
            if s[j] not in ten:
                ten.add(s[j])
                ans += len(set(s[j + 1 :]))
print(ans)

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

-h = set() -for i in range(n - 2): -    ten = set() -    if s[i] not in h: -        h.add(s[i]) -        for j in range(i + 1, n - 1): -            if s[j] not in ten: -                ten.add(s[j]) -                ans += len(set(s[j + 1 :])) +for i in range(10): +    ii = s.find(str(i)) +    if -1 == ii: +        continue +    for j in range(10): +        ij = s.find(str(j), ii + 1) +        if -1 == ij: +            continue +        for k in range(10): +            ik = s.find(str(k), ij + 1) +            if ik != -1: +                ans += 1