N = int(eval(input()))

S = eval(input())



lset = [0]

for c in S:

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



rset = [0]

for c in S[::-1]:

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

rset.reverse()



ptns = [set() for i in range(10)]

for i,c in enumerate(S):

    for j in range(10):

        if lset[i] & (1<<j) == 0: continue

        for k in range(10):

            if rset[i+1] & (1<<k) == 0: continue

            ptns[int(c)].add(j*10 + k)



print((sum(len(p) for p in ptns)))
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())
lset = [0]
for c in S:
    lset.append(lset[-1] | (1 << int(c)))
rset = [0]
for c in S[::-1]:
    rset.append(rset[-1] | (1 << int(c)))
rset.reverse()
ptns = [set() for i in range(10)]
for i, c in enumerate(S):
    for j in range(10):
        if lset[i] & (1 << j) == 0:
            continue
        for k in range(10):
            if rset[i + 1] & (1 << k) == 0:
                continue
            ptns[int(c)].add(j * 10 + k)
print((sum(len(p) for p in ptns)))

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)))

-lset = [0] +lc = [0] -    lset.append(lset[-1] | (1 << int(c))) -rset = [0] +    lc.append(lc[-1] | (1 << int(c))) +rc = [0] -    rset.append(rset[-1] | (1 << int(c))) -rset.reverse() -ptns = [set() for i in range(10)] -for i, c in enumerate(S): -    for j in range(10): -        if lset[i] & (1 << j) == 0: +    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: -        for k in range(10): -            if rset[i + 1] & (1 << k) == 0: +        for j in range(10): +            if r & (1 << j) == 0: -            ptns[int(c)].add(j * 10 + k) -print((sum(len(p) for p in ptns))) +            mem[c].add(10 * i + j) +print((sum(len(m) for m in mem)))