N = int(eval(input()))

S = eval(input())



lc = [0]

for c in S:

    lc.append(lc[-1] | (1<<int(c)))

rc = [0]

for c in S[::-1]:

    rc.append(rc[-1] | (1<<int(c)))

rc.reverse()



mem = [set() for _ in range(10)]

for c,l,r in zip(S,lc,rc[1:]):

    c = int(c)

    for i in range(10):

        if l&(1<<i)==0: continue

        for j in range(10):

            if r&(1<<j)==0: continue

            mem[c].add(10*i+j)

print((sum(len(m) for m in mem)))
N = int(eval(input()))

S = eval(input())



lcs = [0]

rcs = [0]

for c in S:

    c = int(c)

    lcs.append(lcs[-1] | (1<<c))

for c in S[::-1]:

    c = int(c)

    rcs.append(rcs[-1] | (1<<c))

rcs.reverse()



ss = set()

for i,c in enumerate(S):

    c = int(c)

    ls = []

    for l in range(10):

        if lcs[i]&(1<<l):

            ls.append(l)

    rs = []

    for r in range(10):

        if rcs[i+1]&(1<<r):

            rs.append(r)

    for l in ls:

        for r in rs:

            ss.add(l*100 + c*10 + r)

print((len(ss)))
N = int(eval(input()))
S = eval(input())
lc = [0]
for c in S:
    lc.append(lc[-1] | (1 << int(c)))
rc = [0]
for c in S[::-1]:
    rc.append(rc[-1] | (1 << int(c)))
rc.reverse()
mem = [set() for _ in range(10)]
for c, l, r in zip(S, lc, rc[1:]):
    c = int(c)
    for i in range(10):
        if l & (1 << i) == 0:
            continue
        for j in range(10):
            if r & (1 << j) == 0:
                continue
            mem[c].add(10 * i + j)
print((sum(len(m) for m in mem)))

N = int(eval(input()))
S = eval(input())
lcs = [0]
rcs = [0]
for c in S:
    c = int(c)
    lcs.append(lcs[-1] | (1 << c))
for c in S[::-1]:
    c = int(c)
    rcs.append(rcs[-1] | (1 << c))
rcs.reverse()
ss = set()
for i, c in enumerate(S):
    c = int(c)
    ls = []
    for l in range(10):
        if lcs[i] & (1 << l):
            ls.append(l)
    rs = []
    for r in range(10):
        if rcs[i + 1] & (1 << r):
            rs.append(r)
    for l in ls:
        for r in rs:
            ss.add(l * 100 + c * 10 + r)
print((len(ss)))

-lc = [0] +lcs = [0] +rcs = [0] -    lc.append(lc[-1] | (1 << int(c))) -rc = [0] +    c = int(c) +    lcs.append(lcs[-1] | (1 << c)) -    rc.append(rc[-1] | (1 << int(c))) -rc.reverse() -mem = [set() for _ in range(10)] -for c, l, r in zip(S, lc, rc[1:]): -    for i in range(10): -        if l & (1 << i) == 0: -            continue -        for j in range(10): -            if r & (1 << j) == 0: -                continue -            mem[c].add(10 * i + j) -print((sum(len(m) for m in mem))) +    rcs.append(rcs[-1] | (1 << c)) +rcs.reverse() +ss = set() +for i, c in enumerate(S): +    c = int(c) +    ls = [] +    for l in range(10): +        if lcs[i] & (1 << l): +            ls.append(l) +    rs = [] +    for r in range(10): +        if rcs[i + 1] & (1 << r): +            rs.append(r) +    for l in ls: +        for r in rs: +            ss.add(l * 100 + c * 10 + r) +print((len(ss)))