n = int(eval(input()))

s = eval(input())

z1000 = [0 for _ in range(1000)]

l = [-1 for _ in range(10)]

r = [-1 for _ in range(10)]

for i in range(n):

  d = int(s[i])

  if l[d] == -1:

    l[d] = i

for i in range(n)[::-1]:

  d = int(s[i])

  if r[d] == -1:

    r[d] = i

for i in range(n):

  d = int(s[i])

  for dl in range(10):

    for dr in range(10):

      if l[dl] != -1 and r[dr] != -1:

        if l[dl] < i < r[dr]:

          z1000[100*dl+10*d+dr] = 1

#print(l)

#print(r)

#for j in range(1000):

  #if z1000[j] == 1:

    #print(j)

print((sum(z1000)))
n = int(eval(input()))

s = eval(input())

z10 = [0 for _ in range(10)]

z100 = [0 for _ in range(100)]

z1000 = [0 for _ in range(1000)]

for i in range(n):

  x = int(s[i])

  for k in range(100):

    z1000[10*k+x] = z100[k]

  for j in range(10):

    z100[10*j+x] = z10[j]

  z10[x] = 1

print((sum(z1000)))

#for i in range(1000):

  #if z1000[i] == 1:

    #print(i)
n = int(eval(input()))
s = eval(input())
z1000 = [0 for _ in range(1000)]
l = [-1 for _ in range(10)]
r = [-1 for _ in range(10)]
for i in range(n):
    d = int(s[i])
    if l[d] == -1:
        l[d] = i
for i in range(n)[::-1]:
    d = int(s[i])
    if r[d] == -1:
        r[d] = i
for i in range(n):
    d = int(s[i])
    for dl in range(10):
        for dr in range(10):
            if l[dl] != -1 and r[dr] != -1:
                if l[dl] < i < r[dr]:
                    z1000[100 * dl + 10 * d + dr] = 1
# print(l)
# print(r)
# for j in range(1000):
# if z1000[j] == 1:
# print(j)
print((sum(z1000)))

n = int(eval(input()))
s = eval(input())
z10 = [0 for _ in range(10)]
z100 = [0 for _ in range(100)]
z1000 = [0 for _ in range(1000)]
for i in range(n):
    x = int(s[i])
    for k in range(100):
        z1000[10 * k + x] = z100[k]
    for j in range(10):
        z100[10 * j + x] = z10[j]
    z10[x] = 1
print((sum(z1000)))
# for i in range(1000):
# if z1000[i] == 1:
# print(i)

+z10 = [0 for _ in range(10)] +z100 = [0 for _ in range(100)] -l = [-1 for _ in range(10)] -r = [-1 for _ in range(10)] -    d = int(s[i]) -    if l[d] == -1: -        l[d] = i -for i in range(n)[::-1]: -    d = int(s[i]) -    if r[d] == -1: -        r[d] = i -for i in range(n): -    d = int(s[i]) -    for dl in range(10): -        for dr in range(10): -            if l[dl] != -1 and r[dr] != -1: -                if l[dl] < i < r[dr]: -                    z1000[100 * dl + 10 * d + dr] = 1 -# print(l) -# print(r) -# for j in range(1000): -# if z1000[j] == 1: -# print(j) +    x = int(s[i]) +    for k in range(100): +        z1000[10 * k + x] = z100[k] +    for j in range(10): +        z100[10 * j + x] = z10[j] +    z10[x] = 1 +# for i in range(1000): +# if z1000[i] == 1: +# print(i)