N=int(eval(input()))

import copy

S=list(eval(input()))

F=[]

E=[]

L=[0 for i in range(10)]

for i in range(N):

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

    F.append(copy.deepcopy(L))

#print(F)

RS=S[::-1]

L=[0 for i in range(10)]

for i in range(N):

    L[int(RS[i])]=1

    E.append(copy.deepcopy(L))

E=E[::-1]

D={}

for i in range(1,N-1):

    for f in range(10):

        if F[i-1][f]==1:

            for e in range(10):

                if E[i+1][e]==1:

                    if (f,S[i],e) not in D:

                        D[(f,S[i],e)]=1

print((len(D)))

    

#print(E)
N=int(eval(input()))

S=list(eval(input()))

#print(S)

SETF=[set() for i in range(N)]

SETE=[0 for i in range(N)]

ANSSET=set()

SETF[0]=set()

SETF[0].add(S[0])

#print(SETF)

#print(type(SETF[1]))

import copy

for i in range(1,N):

    SETF[i]=copy.deepcopy(SETF[i-1])

    SETF[i].add(S[i])

#print(SETF)



SETE[0]=set()

SETE[0].add(S[-1])

#print(SETE)

for i in range(1,N):

    SETE[i]=copy.deepcopy(SETE[i-1])

    SETE[i].add(S[N-1-i])

SETE=SETE[::-1]



for i in range(1,N-1):

    for f in SETF[i-1]:

        for e in SETE[i+1]:

            ANSSET.add(f+S[i]+e)

print((len(ANSSET)))

#print(SETE)
N = int(eval(input()))
import copy

S = list(eval(input()))
F = []
E = []
L = [0 for i in range(10)]
for i in range(N):
    L[int(S[i])] = 1
    F.append(copy.deepcopy(L))
# print(F)
RS = S[::-1]
L = [0 for i in range(10)]
for i in range(N):
    L[int(RS[i])] = 1
    E.append(copy.deepcopy(L))
E = E[::-1]
D = {}
for i in range(1, N - 1):
    for f in range(10):
        if F[i - 1][f] == 1:
            for e in range(10):
                if E[i + 1][e] == 1:
                    if (f, S[i], e) not in D:
                        D[(f, S[i], e)] = 1
print((len(D)))
# print(E)

N = int(eval(input()))
S = list(eval(input()))
# print(S)
SETF = [set() for i in range(N)]
SETE = [0 for i in range(N)]
ANSSET = set()
SETF[0] = set()
SETF[0].add(S[0])
# print(SETF)
# print(type(SETF[1]))
import copy

for i in range(1, N):
    SETF[i] = copy.deepcopy(SETF[i - 1])
    SETF[i].add(S[i])
# print(SETF)
SETE[0] = set()
SETE[0].add(S[-1])
# print(SETE)
for i in range(1, N):
    SETE[i] = copy.deepcopy(SETE[i - 1])
    SETE[i].add(S[N - 1 - i])
SETE = SETE[::-1]
for i in range(1, N - 1):
    for f in SETF[i - 1]:
        for e in SETE[i + 1]:
            ANSSET.add(f + S[i] + e)
print((len(ANSSET)))
# print(SETE)

+S = list(eval(input())) +# print(S) +SETF = [set() for i in range(N)] +SETE = [0 for i in range(N)] +ANSSET = set() +SETF[0] = set() +SETF[0].add(S[0]) +# print(SETF) +# print(type(SETF[1])) -S = list(eval(input())) -F = [] -E = [] -L = [0 for i in range(10)] -for i in range(N): -    L[int(S[i])] = 1 -    F.append(copy.deepcopy(L)) -# print(F) -RS = S[::-1] -L = [0 for i in range(10)] -for i in range(N): -    L[int(RS[i])] = 1 -    E.append(copy.deepcopy(L)) -E = E[::-1] -D = {} +for i in range(1, N): +    SETF[i] = copy.deepcopy(SETF[i - 1]) +    SETF[i].add(S[i]) +# print(SETF) +SETE[0] = set() +SETE[0].add(S[-1]) +# print(SETE) +for i in range(1, N): +    SETE[i] = copy.deepcopy(SETE[i - 1]) +    SETE[i].add(S[N - 1 - i]) +SETE = SETE[::-1] -    for f in range(10): -        if F[i - 1][f] == 1: -            for e in range(10): -                if E[i + 1][e] == 1: -                    if (f, S[i], e) not in D: -                        D[(f, S[i], e)] = 1 -print((len(D))) -# print(E) +    for f in SETF[i - 1]: +        for e in SETE[i + 1]: +            ANSSET.add(f + S[i] + e) +print((len(ANSSET))) +# print(SETE)