N = int(eval(input()))

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



L = [0] * 10

R = [0] * 10



for i in S:

  R[i] += 1



D = [0] * 1000



L[S[0]] = 1

R[S[0]] -= 1

for i in range(1, N):

  R[S[i]] -= 1

  for j in range(10):

    if L[j] == 0: continue

    for k in range(10):

      if R[k] != 0:

        D[j * 100 + S[i] * 10 + k] = 1

  L[S[i]] = 1

  



ans = 0

for i in D:

  if i == 1:

    ans += 1

print(ans)

N = int(eval(input()))

S = eval(input())



DP = [[0] * 10 for _ in range(10)]

D = [0] * 10

L = [0] * 1000

for i in range(N):

  for j in range(10):

    for k in range(10):

      if DP[j][k] == 1:

        L[j * 100 + k * 10 + int(S[i])] = 1

  for j in range(10):

    if D[j] == 1:

      DP[j][int(S[i])] = 1

  D[int(S[i])] = 1



print((sum(L)))
N = int(eval(input()))
S = list(map(int, list(eval(input()))))
L = [0] * 10
R = [0] * 10
for i in S:
    R[i] += 1
D = [0] * 1000
L[S[0]] = 1
R[S[0]] -= 1
for i in range(1, N):
    R[S[i]] -= 1
    for j in range(10):
        if L[j] == 0:
            continue
        for k in range(10):
            if R[k] != 0:
                D[j * 100 + S[i] * 10 + k] = 1
    L[S[i]] = 1
ans = 0
for i in D:
    if i == 1:
        ans += 1
print(ans)

N = int(eval(input()))
S = eval(input())
DP = [[0] * 10 for _ in range(10)]
D = [0] * 10
L = [0] * 1000
for i in range(N):
    for j in range(10):
        for k in range(10):
            if DP[j][k] == 1:
                L[j * 100 + k * 10 + int(S[i])] = 1
    for j in range(10):
        if D[j] == 1:
            DP[j][int(S[i])] = 1
    D[int(S[i])] = 1
print((sum(L)))

-S = list(map(int, list(eval(input())))) -L = [0] * 10 -R = [0] * 10 -for i in S: -    R[i] += 1 -D = [0] * 1000 -L[S[0]] = 1 -R[S[0]] -= 1 -for i in range(1, N): -    R[S[i]] -= 1 +S = eval(input()) +DP = [[0] * 10 for _ in range(10)] +D = [0] * 10 +L = [0] * 1000 +for i in range(N): -        if L[j] == 0: -            continue -            if R[k] != 0: -                D[j * 100 + S[i] * 10 + k] = 1 -    L[S[i]] = 1 -ans = 0 -for i in D: -    if i == 1: -        ans += 1 -print(ans) +            if DP[j][k] == 1: +                L[j * 100 + k * 10 + int(S[i])] = 1 +    for j in range(10): +        if D[j] == 1: +            DP[j][int(S[i])] = 1 +    D[int(S[i])] = 1 +print((sum(L)))