n=int(eval(input()))

w=eval(input())

d1={}

d2={}

d3={}

for i in range(0,10):

  d1[str(i)]=0

  for j in range(10):

    d2[str(i)+str(j)]=0

    for k in range(10):

      d3[str(i)+str(j)+str(k)]=0

for i in range(len(w)):

  for j in range(10):

    for k in range(10):

      if d2[str(j)+str(k)]>0:

        d3[str(j)+str(k)+w[i]]=1

  for j in range(10):

    if d1[str(j)]>0:

      d2[str(j)+w[i]]=1

  d1[w[i]]+=1

ans=0

for i in d3:

  if d3[i]>0:

    ans+=1

print(ans)
n=int(eval(input()))

l=list(eval(input()))

ans=0

for i in range(10):

  for j in range(10):

    for k in range(10):

      now=str(i)

      count=0

      b=True

      f=1

      while count<n and b:

        if l[count]==now:

          if f==1:

            now=str(j)

            f+=1

          elif f==2:

            now=str(k)

            f+=1

          else:

            b=False

            ans+=1

        count+=1

print(ans)

            
n = int(eval(input()))
w = eval(input())
d1 = {}
d2 = {}
d3 = {}
for i in range(0, 10):
    d1[str(i)] = 0
    for j in range(10):
        d2[str(i) + str(j)] = 0
        for k in range(10):
            d3[str(i) + str(j) + str(k)] = 0
for i in range(len(w)):
    for j in range(10):
        for k in range(10):
            if d2[str(j) + str(k)] > 0:
                d3[str(j) + str(k) + w[i]] = 1
    for j in range(10):
        if d1[str(j)] > 0:
            d2[str(j) + w[i]] = 1
    d1[w[i]] += 1
ans = 0
for i in d3:
    if d3[i] > 0:
        ans += 1
print(ans)

n = int(eval(input()))
l = list(eval(input()))
ans = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            now = str(i)
            count = 0
            b = True
            f = 1
            while count < n and b:
                if l[count] == now:
                    if f == 1:
                        now = str(j)
                        f += 1
                    elif f == 2:
                        now = str(k)
                        f += 1
                    else:
                        b = False
                        ans += 1
                count += 1
print(ans)

-w = eval(input()) -d1 = {} -d2 = {} -d3 = {} -for i in range(0, 10): -    d1[str(i)] = 0 -    for j in range(10): -        d2[str(i) + str(j)] = 0 -        for k in range(10): -            d3[str(i) + str(j) + str(k)] = 0 -for i in range(len(w)): +l = list(eval(input())) +ans = 0 +for i in range(10): -            if d2[str(j) + str(k)] > 0: -                d3[str(j) + str(k) + w[i]] = 1 -    for j in range(10): -        if d1[str(j)] > 0: -            d2[str(j) + w[i]] = 1 -    d1[w[i]] += 1 -ans = 0 -for i in d3: -    if d3[i] > 0: -        ans += 1 +            now = str(i) +            count = 0 +            b = True +            f = 1 +            while count < n and b: +                if l[count] == now: +                    if f == 1: +                        now = str(j) +                        f += 1 +                    elif f == 2: +                        now = str(k) +                        f += 1 +                    else: +                        b = False +                        ans += 1 +                count += 1