import sys

def input():

    return sys.stdin.readline()[:-1]

inf=float("inf")

n=int(eval(input()))

s=eval(input())

dp=[[0]*10,[0]*100,[0]*1000]

for i in range(n):

    for j in range(100):

        if dp[1][j]>=1:

            # print(j*10+int(s[i]))

            dp[2][j*10+int(s[i])]+=1

    for j in range(10):

        if dp[0][j]>=1:

            dp[1][j*10+int(s[i])]+=1

            # print(j*10+int(s[i]))

    dp[0][int(s[i])]+=1

ans=0

# print(dp[0])

# print(dp[1])

for i in range(1000):

    if dp[2][i]>=1:

        ans+=1

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

s=eval(input())

ans=0

for i in range(1000):

  tmp=str(i)

  while len(tmp)<3:

    tmp="0"+tmp

  j=0



  for k in range(n):

    if tmp[j]==s[k]:

      j+=1

    if j==3:

      ans+=1

      break

print(ans)
import sys


def input():
    return sys.stdin.readline()[:-1]


inf = float("inf")
n = int(eval(input()))
s = eval(input())
dp = [[0] * 10, [0] * 100, [0] * 1000]
for i in range(n):
    for j in range(100):
        if dp[1][j] >= 1:
            # print(j*10+int(s[i]))
            dp[2][j * 10 + int(s[i])] += 1
    for j in range(10):
        if dp[0][j] >= 1:
            dp[1][j * 10 + int(s[i])] += 1
            # print(j*10+int(s[i]))
    dp[0][int(s[i])] += 1
ans = 0
# print(dp[0])
# print(dp[1])
for i in range(1000):
    if dp[2][i] >= 1:
        ans += 1
print(ans)

n = int(eval(input()))
s = eval(input())
ans = 0
for i in range(1000):
    tmp = str(i)
    while len(tmp) < 3:
        tmp = "0" + tmp
    j = 0
    for k in range(n):
        if tmp[j] == s[k]:
            j += 1
        if j == 3:
            ans += 1
            break
print(ans)

-import sys - - -def input(): -    return sys.stdin.readline()[:-1] - - -inf = float("inf") -dp = [[0] * 10, [0] * 100, [0] * 1000] -for i in range(n): -    for j in range(100): -        if dp[1][j] >= 1: -            # print(j*10+int(s[i])) -            dp[2][j * 10 + int(s[i])] += 1 -    for j in range(10): -        if dp[0][j] >= 1: -            dp[1][j * 10 + int(s[i])] += 1 -            # print(j*10+int(s[i])) -    dp[0][int(s[i])] += 1 -# print(dp[0]) -# print(dp[1]) -    if dp[2][i] >= 1: -        ans += 1 +    tmp = str(i) +    while len(tmp) < 3: +        tmp = "0" + tmp +    j = 0 +    for k in range(n): +        if tmp[j] == s[k]: +            j += 1 +        if j == 3: +            ans += 1 +            break