from collections import defaultdict

n = int(eval(input()))

S = eval(input())



d1 = defaultdict(int)

d2 = defaultdict(int)

d3 = defaultdict(int)



for s in S:

    for x in d2:

        d3[x+s]+=1

    for y in d1:

        d2[y+s]+=1

    d1[s]+=1



print((len(d3)))
N = int(eval(input()))

S = list(eval(input()))



def ind(l, x, default=-1):

    if x in l:

        return l.index(x)

    else:

        return default



cnt = 0

for i in range(1000):

    tmp = S

    t = str(i).zfill(3)



    pos_1 = ind(tmp,t[0])

    if pos_1>=0:

        tmp = tmp[pos_1+1:]

    elif pos_1 == -1:

        continue



    pos_2 = ind(tmp,t[1])

    if pos_2>=0:

        tmp = tmp[pos_2+1:]

    elif pos_2 == -1:

        continue



    pos_3 = ind(tmp,t[2])

    if pos_3>=0:

        tmp = tmp[pos_3+1:]

    elif pos_3 == -1:

        continue

    cnt += 1

print(cnt)
from collections import defaultdict

n = int(eval(input()))
S = eval(input())
d1 = defaultdict(int)
d2 = defaultdict(int)
d3 = defaultdict(int)
for s in S:
    for x in d2:
        d3[x + s] += 1
    for y in d1:
        d2[y + s] += 1
    d1[s] += 1
print((len(d3)))

N = int(eval(input()))
S = list(eval(input()))


def ind(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default


cnt = 0
for i in range(1000):
    tmp = S
    t = str(i).zfill(3)
    pos_1 = ind(tmp, t[0])
    if pos_1 >= 0:
        tmp = tmp[pos_1 + 1 :]
    elif pos_1 == -1:
        continue
    pos_2 = ind(tmp, t[1])
    if pos_2 >= 0:
        tmp = tmp[pos_2 + 1 :]
    elif pos_2 == -1:
        continue
    pos_3 = ind(tmp, t[2])
    if pos_3 >= 0:
        tmp = tmp[pos_3 + 1 :]
    elif pos_3 == -1:
        continue
    cnt += 1
print(cnt)

-from collections import defaultdict +N = int(eval(input())) +S = list(eval(input())) -n = int(eval(input())) -S = eval(input()) -d1 = defaultdict(int) -d2 = defaultdict(int) -d3 = defaultdict(int) -for s in S: -    for x in d2: -        d3[x + s] += 1 -    for y in d1: -        d2[y + s] += 1 -    d1[s] += 1 -print((len(d3))) + +def ind(l, x, default=-1): +    if x in l: +        return l.index(x) +    else: +        return default + + +cnt = 0 +for i in range(1000): +    tmp = S +    t = str(i).zfill(3) +    pos_1 = ind(tmp, t[0]) +    if pos_1 >= 0: +        tmp = tmp[pos_1 + 1 :] +    elif pos_1 == -1: +        continue +    pos_2 = ind(tmp, t[1]) +    if pos_2 >= 0: +        tmp = tmp[pos_2 + 1 :] +    elif pos_2 == -1: +        continue +    pos_3 = ind(tmp, t[2]) +    if pos_3 >= 0: +        tmp = tmp[pos_3 + 1 :] +    elif pos_3 == -1: +        continue +    cnt += 1 +print(cnt)