def search(num, moji):

    num2str = str(num)

    for i, n in enumerate(moji):

        if n == num2str:

            return moji[i+1:], True

    return "", False





a = int(eval(input()))

b = eval(input())

buf = b[:]

result = 0

for i in range(10):

    buf, flag = search(i, b[:])

    if flag:

        for j in range(10):

            buf2, flag2 = search(j, buf)

            if flag2:

                for k in range(10):

                    _, flag3 = search(k, buf2)

                    if flag3:

                        result += 1

print(result)

N = eval(input())

S = eval(input())

all = "0123456789"

result = 0

for i in all:

    Si = S.find(i)

    if Si != -1:

        for j in all:

            Sj = S[Si+1:].find(j)

            if Sj != -1:

                for k in all:

                    Sk = S[Si+Sj+2:].find(k)

                    if Sk != -1:

                        result += 1



print(result)

def search(num, moji):
    num2str = str(num)
    for i, n in enumerate(moji):
        if n == num2str:
            return moji[i + 1 :], True
    return "", False


a = int(eval(input()))
b = eval(input())
buf = b[:]
result = 0
for i in range(10):
    buf, flag = search(i, b[:])
    if flag:
        for j in range(10):
            buf2, flag2 = search(j, buf)
            if flag2:
                for k in range(10):
                    _, flag3 = search(k, buf2)
                    if flag3:
                        result += 1
print(result)

N = eval(input())
S = eval(input())
all = "0123456789"
result = 0
for i in all:
    Si = S.find(i)
    if Si != -1:
        for j in all:
            Sj = S[Si + 1 :].find(j)
            if Sj != -1:
                for k in all:
                    Sk = S[Si + Sj + 2 :].find(k)
                    if Sk != -1:
                        result += 1
print(result)

-def search(num, moji): -    num2str = str(num) -    for i, n in enumerate(moji): -        if n == num2str: -            return moji[i + 1 :], True -    return "", False - - -a = int(eval(input())) -b = eval(input()) -buf = b[:] +N = eval(input()) +S = eval(input()) +all = "0123456789" -for i in range(10): -    buf, flag = search(i, b[:]) -    if flag: -        for j in range(10): -            buf2, flag2 = search(j, buf) -            if flag2: -                for k in range(10): -                    _, flag3 = search(k, buf2) -                    if flag3: +for i in all: +    Si = S.find(i) +    if Si != -1: +        for j in all: +            Sj = S[Si + 1 :].find(j) +            if Sj != -1: +                for k in all: +                    Sk = S[Si + Sj + 2 :].find(k) +                    if Sk != -1: