N = int(eval(input()))

S = eval(input())



pin1 = {}

pin12 = {}

pin123 = {}



for i in range(N):

    if S[i] not in pin1:

        pin1[S[i]] = 1

        for j in range(i + 1, N):

            if S[i] + S[j] not in pin12:

                pin12[S[i] + S[j]] = 1

                for k in range(j + 1, N):

                    if S[i] + S[j] + S[k] not in pin123:

                        pin123[S[i] + S[j] + S[k]] = 1



print((len(pin123)))

N = int(eval(input()))

S = eval(input())



pin = [[[False] * 11 for _ in range(11)] for _ in range(11)]



for i in range(0, N):

    c = int(S[i])

    for a in range(10):

        for b in range(10):

            if pin[a][b][-1]:

                pin[a][b][c] = True

        if pin[a][-1][-1]:

            pin[a][c][-1] = True

    pin[c][-1][-1] = True



ans = 0

for a in range(10):

    for b in range(10):

        for c in range(10):

            ans += int(pin[a][b][c])



print(ans)
N = int(eval(input()))
S = eval(input())
pin1 = {}
pin12 = {}
pin123 = {}
for i in range(N):
    if S[i] not in pin1:
        pin1[S[i]] = 1
        for j in range(i + 1, N):
            if S[i] + S[j] not in pin12:
                pin12[S[i] + S[j]] = 1
                for k in range(j + 1, N):
                    if S[i] + S[j] + S[k] not in pin123:
                        pin123[S[i] + S[j] + S[k]] = 1
print((len(pin123)))

N = int(eval(input()))
S = eval(input())
pin = [[[False] * 11 for _ in range(11)] for _ in range(11)]
for i in range(0, N):
    c = int(S[i])
    for a in range(10):
        for b in range(10):
            if pin[a][b][-1]:
                pin[a][b][c] = True
        if pin[a][-1][-1]:
            pin[a][c][-1] = True
    pin[c][-1][-1] = True
ans = 0
for a in range(10):
    for b in range(10):
        for c in range(10):
            ans += int(pin[a][b][c])
print(ans)

-pin1 = {} -pin12 = {} -pin123 = {} -for i in range(N): -    if S[i] not in pin1: -        pin1[S[i]] = 1 -        for j in range(i + 1, N): -            if S[i] + S[j] not in pin12: -                pin12[S[i] + S[j]] = 1 -                for k in range(j + 1, N): -                    if S[i] + S[j] + S[k] not in pin123: -                        pin123[S[i] + S[j] + S[k]] = 1 -print((len(pin123))) +pin = [[[False] * 11 for _ in range(11)] for _ in range(11)] +for i in range(0, N): +    c = int(S[i]) +    for a in range(10): +        for b in range(10): +            if pin[a][b][-1]: +                pin[a][b][c] = True +        if pin[a][-1][-1]: +            pin[a][c][-1] = True +    pin[c][-1][-1] = True +ans = 0 +for a in range(10): +    for b in range(10): +        for c in range(10): +            ans += int(pin[a][b][c]) +print(ans)